#2734
Lexicographically Smallest String After Substring Operation
medium · 34.5% accepted · 279 likes · top 12%
Description
Given a string s consisting of lowercase English letters. Perform the following operation:
- Select any non-empty substring then replace every letter of the substring with the preceding letter of the English alphabet. For example, 'b' is converted to 'a', and 'a' is converted to 'z'.
Return the lexicographically smallest string after performing the operation.
Solution