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
We have existing solution for this problem please refer Mirror characters of a string link. We can solve this problem in Python using Dictionary Data Structure. Mirror value of ‘a’ is ‘z’,’b’ is ‘y’ etc, so we create a dictionary data structure and one-to-one map reverse sequence of alphabets onto original sequence of alphabets. Now traverse characters from length k in given string and change characters into it’s mirror value using dictionary.
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course.