Problem 2734 · Medium

Lexicographically Smallest String After Substring Operation

Shift the earliest non-a run back one letter and stop at the next a, since any earlier change would only raise a letter.

Open the interactive visualisation