Problem · String
Lexicographically Smallest String After Substring Operation
Learn this problemProblem statement
You are given a string s consisting of lowercase English letters.
You must choose a non-empty substring and perform the following operation on each character in that substring exactly once: replace it with the previous letter in the alphabet (e.g., b → a, c → b). Note that the previous letter of a is z.
Return the lexicographically smallest string you can obtain after performing the operation exactly once.
Input: one line containing the string s.
Output: one line containing the lexicographically smallest result.
Function
solveLexicographicallySmallestSubstringOperation(input: String) → String[]Examples
Example 1
input = "cbabc"return = ["baabc"]The returned string must match the expected standard output for the sample input.
Constraints
Constraints:
1 <= len(s) <= 100000scontains only lowercase English letters (atoz)