Reported May 2025
Amazongreedy

Find Minimum Machine Sizes

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 May 2025 OA included a resource allocation problem where you size machines to handle computational workloads. The setup is deceptively simple: you have tasks with resource requirements, and you need to find the minimum set of machine configurations that satisfy all of them. This is a classic bin-packing variant, and the trick is recognizing whether a greedy approach works or if you need dynamic programming. StealthCoder will catch you if you freeze on the state representation during the live assessment.

Pattern and pitfall

The core pattern here is either greedy sorting plus assignment, or a DP approach depending on constraints. Most candidates jump to sorting tasks by size and assigning them to the smallest machine that fits, which works for many cases but fails when task ordering matters. The real insight is that this is a bin-packing problem: minimize the number of bins (machines) of fixed or variable capacity needed to pack all items (tasks). If machine sizes are fixed, greedy-first-fit-decreasing often succeeds. If you're optimizing machine capacity itself, you need DP or a more sophisticated packing algorithm. The pitfall: assuming greedy is always optimal. The hedge: during the OA, if your greedy solution times out or fails a test case, you'll know to pivot to DP or a heuristic like best-fit-decreasing.

Drill it cold or hedge it with StealthCoder. Either way, don't walk into the OA hoping you remember the trick.

If this hits your live OA

You can drill Find Minimum Machine Sizes 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. Made for the candidate who got the OA invite this morning and has 72 hours, not six months.

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. Made for the candidate who got the OA invite this morning and has 72 hours, not six months. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Find Minimum Machine Sizes FAQ

Is this a straight bin-packing problem?+

Likely, yes. Bin-packing is NP-hard in general, but OA versions use constraints that make greedy or DP tractable. Sorting tasks by size descending then assigning to the smallest available machine is the most common working approach. Watch out for edge cases: single large task, all identical tasks, tasks that don't fit.

What if greedy doesn't work in my tests?+

Switch to a DP formulation: dp[i] = minimum machines needed to satisfy first i tasks. Or use best-fit-decreasing instead of first-fit. If that still fails, check whether machine capacity is variable (you're solving for optimal machine size) versus fixed. Variable capacity changes the problem entirely.

How do I know if this is NP-hard or polynomial?+

If the problem asks for the exact minimum and constraints are small (n less than 20), it's likely DP or brute force. If n is large (hundreds or thousands) and a greedy solution is hinted, it's probably a polynomial approximation. Test your greedy result against examples to see if it's exact or approximate.

What data structure should I use?+

For greedy: sort the tasks, then use a min-heap to track remaining capacity of each machine. For DP: a 1D array where index is the task count. Avoid over-engineering. A simple list of machine loads works fine if n is small.

How much time should I spend on this in an OA?+

Spend 5 minutes parsing the problem and identifying whether it's bin-packing. Spend 10-15 minutes coding a greedy solution. If that works, move on. If it doesn't, debug for 5 minutes, then pivot to DP or a different heuristic. Don't get stuck on one approach for over 25 minutes total.

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