Reported August 2023
Amazon

Get Minimum Costs

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 Minimum Costs' appeared in assessments through August 2023, and it's a trap if you don't spot the greedy or dynamic-programming angle early. You've got a candidate in front of you who needs to minimize something across a cost structure, and the naive approach will time out or miss the optimal substructure. This is the kind of problem where one insight flips the solution from O(n^2) to O(n log n) or O(n). StealthCoder can surface that insight if you blank on the live OA.

Pattern and pitfall

Without the full problem text, the pattern is likely greedy (pick the minimum cost at each step) or dynamic programming (minimum cost up to each state). Amazon loves cost minimization across sequences, ranges, or transaction chains. The common miss: assuming you can just sort and pick, when actually you need to track state or defend against future costs. The trick usually involves either monotonic ordering, a priority queue to always grab the cheapest option next, or a DP table where each cell represents the minimum cost to reach that point. On the live OA, if you can't articulate whether it's greedy or DP in the first two minutes, StealthCoder will confirm the pattern and give you the skeleton so you don't write the wrong algorithm.

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 Get Minimum Costs 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 Amazon's OA.

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

Get Minimum Costs FAQ

Is this a greedy problem or DP?+

Both appear in Amazon cost minimization problems. If you can prove the greedy choice is safe at every step (no future cost surprises), it's greedy. If future costs depend on past choices, it's DP. Read the problem statement carefully for whether you can undo choices or if you're locked in.

What's the most common pitfall?+

Assuming you can just sort costs and pick the smallest. Amazon often hides a constraint that forces you to respect an order, pick from specific indices, or account for cumulative cost. Always re-read the constraints before coding.

Will priority queue or sorting work?+

Sorting is often a preprocessing step, not the solution. A min-heap (priority queue) is common for always picking the next smallest cost available. But if order matters (you can't pick out of sequence), heap won't work alone.

How should I approach this in the first 3 minutes?+

Identify: are costs independent or does each choice affect future costs? Does order matter? Can you pick any subset or must you pick in order? Answer those three, and the algorithm class becomes obvious.

Is this still being asked at Amazon in 2023-2024?+

Yes. Cost optimization and resource allocation are core Amazon interview themes. This problem family appears regularly. If you see 'minimum' and 'cost' together, expect a greedy or DP solution.

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