Reported December 2024
Amazongreedy

Get Min Removal

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

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

Amazon asked this in December 2024 and you're looking at it cold. Get Min Removal is a removal/optimization problem disguised as a stack question. The core trick: you're removing elements to satisfy a constraint, and the greedy choice is always to dump the larger element when you hit a conflict. It's the kind of problem where the first 30 seconds of clarity matter more than brute force. StealthCoder will catch you if the greedy intuition slips during the live OA.

Pattern and pitfall

The pattern here is greedy plus stack mechanics. You iterate through the input, maintain a monotonic structure (usually increasing), and when a new element breaks the order, you pop elements that violate the constraint. The key insight: you want to remove the minimum number of elements, so you remove larger elements first when you have the choice. This is not dynamic programming or backtracking. It's a single pass with a stack where each element is visited once. The pitfall: candidates overthink the removal logic and try to compute optimal subsets. Don't. The greedy stack approach is optimal. If you blank on the pattern during the OA, StealthCoder gives you the stack skeleton in real time.

StealthCoder is the hedge for the one pattern you didn't drill. It runs invisibly during the screen share.

If this hits your live OA

You can drill Get Min Removal 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. If you're reading this with an OA window open, you're who this was built for.

Get StealthCoder

Related leaked OAs

⏵ Practice the LeetCode equivalent

This OA pattern shows up on LeetCode as remove k digits. If you have time before the OA, drill that.

⏵ The honest play

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

Amazon reuses patterns across OAs. If you're reading this with an OA window open, you're who this was built for. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Get Min Removal FAQ

Is this actually a stack problem or a DP problem?+

Stack with greedy. You maintain a monotonic stack and pop when the invariant breaks. DP is overkill. The greedy choice (remove larger elements first) is safe because you process left to right and never need to backtrack.

What's the removal constraint I should expect?+

Most likely: remove minimum elements to make the sequence strictly increasing, non-decreasing, or satisfy some order property. Read the exact constraint in your problem. The mechanics are the same regardless.

How do I code this in under 10 minutes?+

Write a stack loop. For each element, while the stack is non-empty and the top violates your constraint, pop and increment removal count. Push the current element. Return removal count. That's it. No fancy data structures.

Will Amazon ask this in different ways or is the pattern locked?+

The pattern is locked. Greedy stack removal. The surface story changes (strictly increasing, remove K duplicates, etc.) but the algorithm is the same. Learn the skeleton once.

What's the most common mistake candidates make?+

Trying to precompute which elements to remove instead of using the stack to decide on the fly. They also forget that popping consumes your 'removal budget' (if K removals are allowed). Track removals as you pop.

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

OA at Amazon?
Invisible during screen share
Get it