Mirror String
You are given a string S containing only uppercase English characters. Find whether S is the same as its reflection in the mirror.
For Example, S = “AMAMA” is the same as its reflection in the mirror.
Input Format:
The first line of input contains an integer T, denoting the number of test cases.
The first line of each test case contains a string 'S'.
Output Format:
For each test case, print a single line containing “YES” or “NO” depending on whether the string 'S' is the same as its reflection in the mirror or not.
The output of each test case is printed in a separate line.
Note:
You do not need to print anything, it has already been taken care of. Just implement the function.
The return type of the function is boolean, which returns true if the string is the same as its reflection in the mirror, otherwise returns false.
Constraints
1 <= T <=10
1 <= Length(S) <= 10 ^ 5
Where ‘T’ is the number of test cases, ‘S’ is the string given in input.
Time limit: 1sec.
CodingNinjas
author
2y
Check Palindrome and Symmetricity
For a string to be same as its reflection in the mirror, it should satisfy the following conditions:
- The given string “S” needs to be a palindrome.
- All the characters of...read more
Vamsi dheeraj Tula
1y
def solve(s):
ref="AHIMOTUVWXY"
for i in s:
if i not in ref:
return 'NO'
if s==s[::-1]:
return "YES"
return "NO"
Help your peers!
Add answer anonymously...
Top TCS System Engineer interview questions & answers
Popular interview questions of System Engineer
Top HR questions asked in TCS System Engineer
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