Reported August 2024
Amazonbinary search

Minimize Maximum Parcels

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 August 2024, and it's a classic min-max problem disguised as a logistics puzzle. You're trying to distribute parcels across some number of containers or routes such that the maximum load on any single container is as small as possible. The trap is thinking greedy. The pattern is binary search on the answer space, paired with a validation function that checks whether a given max-load is achievable. StealthCoder will have this ready if the approach doesn't click immediately during your OA.

Pattern and pitfall

The core trick: you don't iterate through possible answers. Instead, you binary search on the range of feasible maximum loads. The lower bound is the single largest parcel. The upper bound is the sum of all parcels. For each candidate max-load, you greedily pack parcels into containers, stopping when the next parcel won't fit, then starting a new container. Count how many containers you needed. If it's within budget, the max-load is valid, so search lower. If not, search higher. This is a textbook binary search on the answer pattern, and it's efficient enough to handle large inputs. The common pitfall is trying to optimize the packing order itself instead of just validating feasibility for a fixed max-load threshold.

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 Minimize Maximum Parcels 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.

Minimize Maximum Parcels FAQ

Is this just a greedy packing problem?+

No. Greedy alone won't minimize the maximum. You need binary search to explore the answer space efficiently. The greedy part is only the validation step: given a max-load, can you pack all parcels into k containers? That's where greedy works.

What if parcels are identical?+

The approach is unchanged. Binary search on max-load. Validate by simulating packing. Even with identical parcels, the structure of the problem remains: find the smallest possible worst-case load.

How do I know when to stop binary searching?+

When left and right bounds converge (left >= right), you've found the minimum possible maximum load. Track the answer whenever you find a valid configuration, then search for smaller possibilities.

What's the time complexity?+

O(n log S) where n is the number of parcels and S is the sum of all weights. Log S comes from the binary search range, and n is the cost of validating each candidate answer.

Should I sort the parcels first?+

Sorting doesn't help min-max. The binary search approach works on any order. Focus on the search logic and the validation function, not the input arrangement.

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