IBMOA #43
Get Smallest String
Estimated MediumJudge-ready
Choose exactly one non-empty contiguous substring and replace each letter in it with the previous letter, where a becomes z. Find the lexicographically smallest string after the operation.
Input
One line containing a lowercase string of length 1..100000.
Output
Output the smallest string after the operation.
Example 1
Input:
hackerrank
Output:
gackerrank
Example 2
Input:
bbcad
Output:
aabad
Example 3
Input:
aaa
Output:
aaz
Example notes
The examples give gackerrank, aabad and aaz respectively.
Editorial
Loading solution…