Palindrome String Check
Given an alphabetical string S
, determine whether it is a palindrome. A palindrome is a string that reads the same backward as forward.
Input:
The first line contains an integer T
, the number of test cases.
Each of the following T
lines contains a single alphabetical string S
.
Output:
For each test case, output 1
if the string S
is a palindrome, otherwise output 0
. Print the result for each test case on a new line.
Example:
Input:
T = 1
S = "racecar"
Output:
1
Explanation:
The string S = "racecar"
is the same when reversed. Therefore, it is a palindrome and the output is 1
.
Constraints:
1 ≤ T ≤ 1000
1 ≤ |S| ≤ 105
S
consists of only lowercase English alphabets.- The sum of lengths of all test cases
Σ|S| ≤ 2 * 106
- Time limit: 1 second
Be the first one to answer
Add answer anonymously...
Top Tredence Business Analyst interview questions & answers
Popular interview questions of Business Analyst
Stay ahead in your career. Get AmbitionBox app
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+
Reviews
4 L+
Interviews
4 Cr+
Salaries
1 Cr+
Users/Month
Contribute to help millions
Get AmbitionBox app