#C2901. Preceding Characters Transformation
Preceding Characters Transformation
Preceding Characters Transformation
You are given a string S
consisting of lowercase English letters. Your task is to transform the string by replacing each character with its preceding character in the English alphabet. Note that if the character is a
, it should wrap around to z
.
For example, if S = "abc"
, the transformed string should be "zab"
because:
- 'a' becomes 'z'
- 'b' becomes 'a'
- 'c' becomes 'b'
Hint: For a character c
not equal to 'a', its preceding character can be calculated using the formula: \( \text{prev}(c) = \text{chr}(\text{ord}(c) - 1) \).
inputFormat
Input is provided via standard input (stdin). It consists of a single line that contains a non-empty string S made up of lowercase English letters.
outputFormat
Print to standard output (stdout) a single line representing the transformed string after replacing each character with its preceding character (with 'a' replaced by 'z').## sample
abc
zab