#include
using namespace std;
bool palindrome(int a[],int n)
{
for(int j=0;j<n;j++)
{
if(a[j]==a[j-n-1])
return true;
else
return false;
}
}
int main()
{ int n;
cin>>n;
int arr[1000];
for(int i=0;i<n;i++)
{ cin>>arr[i];
}
cout<<palindrome(arr,n);
return 0;
}
What is wrong in the code
@Vibhuti0206
Compare a[j] with a[n-j-1] instead of a[j-n-1] .
if (a[j] == a[n - j - 1])
Also , print “true” or “false” instead of 1 and 0.