Problem with code; not able to understand why I am not able to get the required output

#include<bits/stdc++.h>
using namespace std;
bool check(char arr[],int n)
{
char left;
left=arr[0];
char right;
right=arr[n-1];

//Base case

if(strlen(arr)==0||strlen(arr)==1)
{
return true;
}
//Recursive case
else if(check(arr,left)==check(arr,right))
{
return true;
}
else
{
return false;
}

}
int main()
{
char arr[10000];
int n;
cin>>n;
for(int i=0;i<n;i++)
{
cin>>arr[i];
}

check(arr,n);

}

@harshulgarg21
hello harshul,

ur recurrence relation should be like
check(arr,i,j) -> i>=j return true // base case
. … . . . . . . . . . if (arr[i]==arr[j] and check(arr,i+1,j-1)) == true then return true
. … . . . . . . . . .otherwise return false;

#include
using namespace std;
bool check(int arr[],int i,int j)
{
if(i>=j)
{
return true;
}
if((arr[i]=arr[j] && check(arr,i+1,j-1))==true)
{
return true;
}
else
{
return false;
}
}
int main()
{
int arr[1000];
int n;
cin>>n;
for(int i=0;i<n;i++)
{
cin>>arr[i];
}
int i=arr[0];
int j=arr[n-1];
if(check(arr,i,j))
{
cout<<“true”;
}
else{
cout<<“false”;
}
return 0;
} i have written code accoding to you but I am always geeting true as the output. Pls assist for the above code

@harshulgarg21
intialise
i=0
j=n-1

I am still not getting the correct ans can you pls make the necessary changes in the code

@harshulgarg21

pls check this -> https://ide.codingblocks.com/s/201557

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.