Reported November 2024
Amazondynamic programming

Get Min Change

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's 'Get Min Change' showed up in November 2024 OAs, and it's a classic coin change trap. You'll see a target amount and a set of denominations, and your job is to find the minimum number of coins needed to make that amount. The catch: not every amount is reachable, and greedy doesn't work. This is dynamic programming territory, and if you blank during the live OA, StealthCoder will have the pattern ready so you don't tank the submission.

Pattern and pitfall

The trick is that you can't just grab the biggest coins first. A greedy approach fails on real currency sets. You need DP: create an array where each index represents an amount, and store the minimum coin count to reach it. Base case is amount 0 equals 0 coins. For each amount, try every coin denomination smaller than or equal to it, and take the minimum result from a previous state. If an amount is unreachable, return -1 or an impossible flag. The pattern is bottom-up DP with a state transition that compares all coin options. During your live OA, if the logic slips, StealthCoder catches the algorithm in real time and shows you the recurrence.

If you see this problem in your OA tomorrow, the play is to recognize the pattern in 30 seconds. StealthCoder buys you that recognition.

If this hits your live OA

You can drill Get Min Change 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 passed his OA cold and still thinks the filter is broken.

Get StealthCoder

Related leaked OAs

⏵ Practice the LeetCode equivalent

This OA pattern shows up on LeetCode as coin change. 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. Built by an Amazon engineer who passed his OA cold and still thinks the filter is broken. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Get Min Change FAQ

Is this really asking for minimum coins, or something else?+

Yes, minimum coin count to reach the target amount. If the amount is impossible to make with the given denominations, return -1. Amazon often includes edge cases where no solution exists, so check that.

Will greedy work if the coins are sorted?+

No. Greedy fails on non-canonical coin systems. For example, coins [1, 3, 4] and amount 6 requires 2 coins (3+3), not greedy's 3 (4+1+1). You must use DP.

What's the time and space complexity I should aim for?+

O(n*m) time and O(n) space, where n is the target amount and m is the number of coin types. DP with a 1D array is the standard approach. That's tight enough for Amazon's constraints.

Do I need to track which coins were used, or just the count?+

The problem asks for minimum count, not the actual coins. If Amazon later asks for the coin list itself, that's a follow-up. For now, store only the minimum count at each amount.

How do I handle the case where an amount can't be made?+

Initialize your DP array with a sentinel like infinity or -1 for unreachable amounts. At the end, if dp[target] is still infinity or -1, return that value. Amazon expects you to handle infeasibility cleanly.

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