Problem · String
Lexicographically Smallest String After Substring Operation
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.
Examples
01 · 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)
More Point72 problems
public String[] solveLexicographicallySmallestSubstringOperation(String input) {
// write your code here
}
input"cbabc"
expected["baabc"]
checking account