Given a string s consisting of lowercase English letters, return a new string where each character is replaced by its alphabetical mirror.
The character 'a' maps to 'z', 'b' maps to 'y', 'c' maps to 'x', and so on. Formally, the character at position i counted from 'a' maps to the character at position i counted back from 'z'.
Function Signature
def mirror_characters(s: str) -> str:
Constraints
-
1 <= len(s) <= 10^5
-
s
consists of lowercase English letters only.
Examples
Input: s = "abc"
Output: "zyx"
'a' becomes 'z', 'b' becomes 'y' and 'c' becomes 'x', so "abc" becomes "zyx".
Input: s = "hello"
Output: "svool"
'h' is 7 letters after 'a', so it becomes 's', 7 letters before 'z'. In the same way 'e' becomes 'v', each 'l' becomes 'o' and 'o' becomes 'l'.
Input: s = "mn"
Output: "nm"
'm' and 'n' are the middle pair of the alphabet, so they swap with each other.