Reported May 2026
Point 72greedy

Lexicographically Smallest String After Substring Operation

Reported by candidates from Point 72's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.

Get StealthCoderRuns invisibly during the live Point 72 OA. Under 2s to a working solution.
Founder's read

Point 72 asked this in May 2026. You have a string, you pick one contiguous substring, and you shift every character back one letter in the alphabet (b becomes a, a becomes z). The catch: you want the lexicographically smallest result. This is a greedy problem wearing a sliding-window coat. The trick is knowing when to start the operation and when to stop. StealthCoder will have the solution pattern locked in seconds if you freeze during the OA.

The problem

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. The returned string must match the expected standard output for the sample input. Use the limits and requirements stated in the prompt.

Reported by candidates. Source: FastPrep

Pattern and pitfall

The greedy insight: start decrementing at the first character that's not 'a' (since 'a' becomes 'z', making it worse). Keep decrementing while the next character is greater than the current one. Stop as soon as you hit a character that's smaller or equal, because decrementing it would make the string worse. Walk through 'leetcode': 'l' is not 'a', so start. 'e' > 'l' after decrement, so continue. 'e' equals 'e' after decrement, so stop. Result: 'kddsbncd'. Edge case: 'aaaa' has no non-'a' characters, so you must pick at least one substring. Picking the whole thing turns all 'a's to 'z's, which is the lexicographically smallest forced outcome. This is a single pass with a clear stopping condition. StealthCoder handles edge cases and boundary logic instantly.

The honest play: practice the pattern, and have StealthCoder ready for the one you didn't see coming.

If this hits your live OA

You can drill Lexicographically Smallest String After Substring Operation cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. Built for the candidate who saw this exact problem leak two days before his OA and wondered if anyone had a play.

Get StealthCoder

Related leaked OAs

⏵ The honest play

You've seen the question. Make sure you actually pass Point 72's OA.

Point 72 reuses patterns across OAs. Built for the candidate who saw this exact problem leak two days before his OA and wondered if anyone had a play. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Lexicographically Smallest String After Substring Operation FAQ

Why does 'aaaa' become 'zzzz' and not stay 'aaaa'?+

You must perform the operation on a non-empty substring at least once. All characters are 'a', and 'a' decrementing gives 'z'. Decrementing any substring makes the result worse than 'aaaa', so the lexicographically smallest forced outcome is the whole string: 'zzzz'.

How do I know when to stop decrementing?+

Stop as soon as the next character (after decrement) would be less than or equal to the current character (after decrement). Continuing would create a larger substring and make earlier positions worse. Greedy: stop early.

What if the entire string is one decreasing run?+

Decrement the entire string. There's no stopping point because every character is less than the previous one after decrement. Rare, but the algorithm handles it naturally by continuing to the end.

Is this actually a sliding-window problem?+

Not in the classic sense. You're not shrinking and expanding a window. You're finding the optimal contiguous range to decrement using a greedy, single-pass approach. The hint might be misleading. Think greedy first.

How do I handle wraparound (a becoming z)?+

Use modular arithmetic. In code: (c - 'a' - 1 + 26) % 26 + 'a'. This ensures 'a' wraps to 'z' and all other letters decrement correctly. Test it with the examples before submission.

Problem reported by candidates from a real Online Assessment. Sourced from a publicly-available candidate-aggregated repository. Not affiliated with Point 72.

OA at Point 72?
Invisible during screen share
Get it