text of lowercase English letters. Exactly once, pick a non-empty stretch of consecutive characters and replace every letter in it with the one before it in the alphabet: b → a, c → b and so on, while a wraps around to z.
Return the lexicographically smallest string this operation can produce.text="dbaca" → 'caaca'
The best stretch is db, which turns into ca. Taking the a too would turn it into z.
text="abcab" → 'aabab'
There is no point touching the leading a; shift bc into ab.
text="aaa" → 'aaz'
The stretch must be non-empty and any a becomes z, so it does the least harm at the very end.
text consists of lowercase English letterstext="dbaca"
'caaca'
Run checks the first 3 tests in your browser. Submit checks all 104 tests on the server, hidden ones included.