


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.
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.
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.
1
ITATI
YES
String “ITATI” is the same as its reflection in the mirror.
2
MMMM
MZM
YES
NO
Check for symmetricity of the characters of the string.
For a string to be same as its reflection in the mirror, it should satisfy the following conditions:
O(N), where N is the length of the string.
So, the final time complexity is O(N + N) = O(N).
O(1).
Only constant additional space is required to store the symmetric characters.