Practice Lexicographically Smallest String After Substring Operation
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
Choose exactly one nonempty contiguous substring of lowercase s. Replace each of its letters by the preceding alphabet letter, with a wrapping to z. Return the lexicographically smallest resulting full string.
Source: Lexicographically Smallest String After Substring Operation on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
Input
s = "cbabc"
Output
"baabc"
# Example 2
Input
s = "aa"
Output
"az"
# Example 3
Input
s = "acbbc"
Output
"abaab"
# Example 4
Input
s = "leetcode"
Output
"kddsbncd"
Constraints
1 <= s.length <= 3 * 10^5
s consists of lowercase English letters
Related LeetCode Problems
Practice more problems similar to Lexicographically Smallest String After Substring Operation.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.