Basic implementation output not coming

I have tried to implement the basic recursive solution as shown in hint video.Can i know why is it wrong?

atleast for some case it should work right?

Hey @pranjalarora98
Please share ur code in CB ide :slight_smile:

#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

Hey @pranjalarora98
Mentioned the change in comments : https://ide.codingblocks.com/s/375785 :slight_smile:
But none of the testcases will pass because constraints are tight
You have to solve it with efficient method :slight_smile:

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.