FastPrepFastPrep
Problem Brief

Lexicographically Smallest String After Substring Operation

FULLTIMEOA

Complete the function below. The function receives the full standard input as a single string and must return the exact standard output lines for the described problem.

Original prompt

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 once.

I/O

Input: one line string s Output: one line string, the lexicographically smallest result

Constraints

1 <= len(s) <= 1e5 s contains only a to z

Examples

Input: cbabc Output: baabc Input: aaaa Output: zzzz Input: leetcode Output: kddsbncd

Function Description

Complete solveLexicographicallySmallestSubstringOperation. It has one parameter, String input, containing the full stdin payload. Return the stdout payload as an array of lines, without trailing newline characters.

1Example 1

Input
input = "cbabc"
Output
["baabc"]
Explanation

The returned string must match the expected standard output for the sample input.

Constraints

Limits and guarantees your solution can rely on.

Use the limits and requirements stated in the prompt.

public String[] solveLexicographicallySmallestSubstringOperation(String input) {
    // write your code here
}
Input

input

"cbabc"

Output

["baabc"]

Sign in to submit your solution.