Reported July 2026
Ripplingstack

Lexicographically Minimum Stack Encryption

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

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

The mistake that sinks a first attempt on this Rippling OA, reported in July 2026, is popping the stack too early or too late. You push characters from the original string onto a temp stack, pop them into the output, and want the smallest possible result. It's the classic stack-with-greedy setup, and it's a known pattern. If you blank when the clock is running, StealthCoder runs invisibly on your desktop and can hand you the solution as a safety net. But the trick is short enough to learn tonight.

The problem

You are given a string originalString. Start with two empty strings: temporaryString and encryptedString.
Repeat either of the following operations until both originalString and temporaryString are empty:
Remove the first character of originalString and append it to temporaryString.
Remove the last character of temporaryString and append it to encryptedString.
Choose the operation order that produces the lexicographically smallest possible encryptedString, and return that string.

Function
minimumEncryptedString(originalString: String) → String

Examples
Example 1
originalString = "dby"
return = "bdy"
Move d and then b into the temporary stack. Pop b first, then arrange the remaining legal moves to produce bdy.
Example 2
originalString = "vgxgpu"
return = "ggpuxv"
The minimum legal encrypted string is ggpuxv.

Constraints
1 <= originalString.length() <= 200000
originalString contains lowercase English letters.

Reported by candidates. Source: FastPrep

Pattern and pitfall

The trick is greedy with a suffix minimum. Precompute, for each index, the smallest character in the remaining original string. Push characters onto the stack one by one. Before each push, or after it, check the top of the stack: if it's less than or equal to the smallest character still unread, pop it to the output. Otherwise keep pushing. When the input runs out, pop everything left. The common pitfall is comparing the stack top against the next character only, instead of the minimum of the whole remaining suffix. That gives wrong answers on strings like vgxgpu. The other pitfall is O(n^2) scanning for the minimum, which dies at 200000 characters. Use a 26-length count array or a suffix-min array for O(n) time. If you freeze during the live OA, StealthCoder is the hedge that reads the problem and gives you this logic.

If this hits your live OA and you blank, StealthCoder solves it in seconds, invisible to the proctor.

If this hits your live OA

You can drill Lexicographically Minimum Stack Encryption 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 by an Amazon engineer who would have shipped this the night before his JPMorgan OA if he'd had it.

Get StealthCoder

Related leaked OAs

⏵ The honest play

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

Rippling reuses patterns across OAs. Built by an Amazon engineer who would have shipped this the night before his JPMorgan OA if he'd had it. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Lexicographically Minimum Stack Encryption FAQ

What's the trick in the Rippling Lexicographically Minimum Stack Encryption problem?+

Greedy with a stack. Keep track of the smallest character left in the unread part of the string. Pop the stack top to the output whenever it's less than or equal to that minimum. Otherwise push the next character. Flush the stack at the end.

How hard is this problem really?+

Medium. The stack idea is obvious from the statement, but the pop condition is where people slip. Once you see that you compare against the suffix minimum, the code is about 15 lines. Most failures come from wrong comparisons, not from complexity.

Why does comparing only to the next character fail?+

The next character may be larger than a smaller one coming later. If you pop too early, you lock in a bigger letter before a smaller one can come out first. The suffix minimum tells you whether something smaller is still waiting, so you know to hold.

What complexity do I need for 200000 characters?+

O(n) time and O(n) space. Use a count array of 26 letters, decrementing as you push, or a precomputed suffix-min array. Rescanning the remainder for every step is O(n^2) and will time out at this input size.

How do I prepare for this in 48 hours?+

Solve two or three stack-greedy problems, like the classic lexicographically smallest string using a stack. Write the suffix-min version from memory, then test it on dby and vgxgpu. Check edge cases: a single character, all equal letters, and a descending string.

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

OA at Rippling?
Invisible during screen share
Get it