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 the string must be symmetric so that the reflection of the characters remains the same.
- The symmetric characters are AHIMOTUVWXY.
- Store the symmetric characters in an unordered set, traverse the string, and if the string contains any non-symmetric character, then return false.
- If all the characters present in the string are symmetric, then check if the string is a palindrome or not. If the string is a palindrome, then return true, otherwise, return false.
Time Complexity : O(N)
Space Complexity : O(1)