Given a string S containing only uppercase English characters. The task is to find whether S is the same as its reflection in a mirror.
Input: str = "AMA" Output: YES AMA is same as its reflection in the mirror. Input: str = "ZXZ" Output: NO
Approach: The string obviously has to be a palindrome, but that alone is not enough. All characters in the string should be symmetric so that their reflection is also the same. The symmetric characters are AHIMOTUVWXY.
- Store the symmetric characters in an unordered_set.
- Traverse the string and check if there is any non-symmetric character present in the string. If yes then return false.
- Else check if the string is palindrome or not. If the string is palindrome also then return true else return false.
Below is the implementation of the above approach:
Time Complexity: O(N)
- Mirror characters of a string
- Check if mirror image of a number is same if displayed in seven segment display
- Python Dictionary to find mirror characters in a string
- String slicing in Python to check if a string can become empty by recursive deletion
- Check if a string can be converted to another string by replacing vowels and consonants
- Check if a string can become empty by recursively deleting a given sub-string
- Check if a string can be obtained by rotating another string 2 places
- Check whether second string can be formed from characters of first string
- Check if a string can be repeated to make another string
- Check if a string contains a palindromic sub-string of even length
- Check if a given string is sum-string
- Check if a string has m consecutive 1's or 0's
- Check if a string is suffix of another
- Check if a string is the typed name of the given name
- Check whether a given string is Heterogram or not