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.
Don’t stop now and take your learning to the next level. Learn all the important concepts of Data Structures and Algorithms with the help of the most trusted course: DSA Self Paced. Become industry ready at a student-friendly price.
- Return maximum occurring character in an input string
- Print all the duplicates in the input string
- Remove characters from the first string which are present in the second string
- Remove duplicates from a given string
- Print reverse of a string using recursion
- Write a program to print all permutations of a given string
- Divide a string in N equal parts
- Given a string, find its first non-repeating character
- Write a program to reverse an array or string
- Print list items containing all characters of a given word
- Reverse words in a given string
- Find the smallest window in a string containing all characters of another string
- Length of the longest substring without repeating characters
- Print all permutations with repetition of characters
- Interleaving of two given strings with no common characters
- Lexicographic rank of a string
- An in-place algorithm for String Transformation
- Count words in a given string
- String matching where one string contains wildcard characters
- Remove "b" and "ac" from a given 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