I have tried to implement the basic recursive solution as shown in hint video.Can i know why is it wrong?
Basic implementation output not coming
atleast for some case it should work right?
#include<iostream>
#include
int func(int i,int j,std::string str)
{
if(i>=j)
return 1;
return func(i+1,j-1,str) && str[i]==str[j];
}
int main () {
int i,j,n,t,l,r;
std::string str;
std::cin>>n;
std::cin>>str;
std::cin>>t;
while(t–)
{
std::cin>>l>>r;
std::cout<<func(l,r,str);
}
}
please share ur code in IDE
- Go to ide.codingblocks.com
- Paste ur code
- Press ctrl+S
- Click on save
- Paste the url here
Hey @pranjalarora98
Mentioned the change in comments : https://ide.codingblocks.com/s/375785
But none of the testcases will pass because constraints are tight
You have to solve it with efficient method
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.