Given a string s check if it is palindrome or not.
Input:
The first line contains 'T' denoting the number of test cases. Then follows description of test cases.
Each case begins with a single integer N denoting the length of string. The next line contains the string s.
The first line contains 'T' denoting the number of test cases. Then follows description of test cases.
Each case begins with a single integer N denoting the length of string. The next line contains the string s.
Output:
Print "Yes" if it is a palindrome else "No". (Without the double quotes)
Constraints:
1<=T<=30
1<=N<=100
Example:
Input:
1
4
abba
Output:
Yes
Yes
Your Code
#include<iostream>
using namespace std;
#include<string.h>
int main()
{
int t ;
cin>>t;
while(t--)
{ int x;
cin>>x;
string s;
cin.ignore();
getline(cin,s);
int i, temp=1;
for(i=0; i<x; i++)
{
if(s[i]!=s[x-i-1])
{ temp=0;
break;
}
}
if(temp==1)
cout<<"Yes"<<endl;
else
cout<<"No"<<endl;
}
return 0;
}