Given a string and a number N, we need to mirror the characters from N-th position up to the length of the string in the alphabetical order. In mirror operation, we change ‘a’ to ‘z’, ‘b’ to ‘y’, and so on.
Input : N = 3 paradox Output : paizwlc We mirror characters from position 3 to end. Input : N = 6 pneumonia Output : pnefnlmrz
Below are different characters and their mirrors.
Mirroring the alphabetical order means that a corresponds to z, b corresponds to y. Which means that first character becomes the last and so on. Now, to achieve this we maintain a string(or a character array) which contains the English alphabets in lower case. Now from the pivot point up to the length, we can look up the reverse alphabetical order of a character by using its ASCII value as an index. Using the above technique, we transform the given string in the required one.
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Python Dictionary to find mirror characters in a string
- Check if the given string is the same as its reflection in a mirror
- Count of ungrouped characters after dividing a string into K groups of distinct characters
- Rearrange the characters of the string such that no two adjacent characters are consecutive English alphabets
- Permutation of a string with maximum number of characters greater than its adjacent characters
- Min flips of continuous characters to make all characters same in a string
- String with k distinct characters and no same characters adjacent
- Minimal moves to form a string by adding characters or appending string itself
- Transform string str1 into str2 by taking characters from string str3
- Lexicographically smallest string formed by appending a character from the first K characters of a given string
- Lexicographically smallest string formed by appending a character from first K characters of a string | Set 2
- Create a new string by alternately combining the characters of two halves of the string in reverse
- Minimum deletions from string to reduce it to string with at most 2 unique characters
- Find Kth largest string from the permutations of the string with two characters
- Count of times second string can be formed from the characters of first string
- Minimize length of prefix of string S containing all characters of another string T
- Find the smallest window in a string containing all characters of another string
- Check whether second string can be formed from characters of first string
- String matching where one string contains wildcard characters
- Remove characters from the first string which are present in the second string
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.
Improved By : Sam007