You're given an alphabetical string ‘S’.
Determine whether it is palindrome or not. A palindrome is a string that is equal to itself upon reversing it.
‘S’ = racecar
The reverse of ‘S’ is: racecar
Since ‘S’ is equal to its reverse. So ‘S’ is a palindrome.
Hence output will be 1.
Input Format:
The first line of the input contains a single integer ‘T’ representing the no. of test cases.
The first line of each test case contains a single alphabetical string, ‘S’.
Output Format:
For each test case, print a single integer value 1 if the given string ‘S’ is palindrome and 0 otherwise.
Print a separate line for each test case.
You are not required to print anything; it has already been taken care of. Just implement the function and return the answer.
Constraints -
1 ≤ T ≤ 1000
1 ≤ |S| ≤ 10^5
S consists of only lowercase english alphabets.
Σ|S| ≤ 2 * 10^6
Time limit: 1 Sec
2
racecar
niinja
1
0
For First Case - Same as explained in above example.
For the second case -
‘S’ = niinja
Reverse of ‘S’ is: ajniin
Since ‘S’ is not equal to its reverse. So ‘S’ is not a palindrome.
Hence output will be 0.
2
level
panama
1
0
Check each element from the first half to its corresponding element in the second half.