Reported April 2025
Amazongreedy

Min Dock Bays

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 Min Dock Bays question shows up in their OA and it's a scheduling optimization puzzle that looks simpler than it is. You're given a list of truck arrival and departure times, and you need to find the minimum number of dock bays required so no truck waits. The trick isn't greedy, it's interval overlap. This is the kind of problem where your first instinct might waste 10 minutes on the wrong approach. StealthCoder catches that hesitation and gives you the pattern instantly when you're on the clock.

Pattern and pitfall

This is a classic interval overlap or meeting rooms problem in disguise. The pattern: sort events by time, then track active intervals using a sweep line or priority queue. Every arrival increments the dock count, every departure decrements it. The answer is the maximum concurrent overlaps you see. Most candidates jump to greedy assignment and get stuck. The real insight is that you don't need to assign specific trucks to specific bays, just count how many trucks are in the dock at the same time. If you blank on the ordering or the sweep logic during the live OA, StealthCoder reads the problem and hands you the exact approach without the proctor seeing it.

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 Min Dock Bays 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

⏵ Practice the LeetCode equivalent

This OA pattern shows up on LeetCode as meeting rooms ii. 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. 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.

Min Dock Bays FAQ

Is this about greedy truck assignment?+

No. You're not matching trucks to bays. You're finding the peak number of trucks present at once. Sort all events, sweep through them, track the running count. Max count is your answer. Greedy fails here.

What if arrival and departure happen at the same time?+

The typical convention is process departures before arrivals at the same timestamp. That way a truck leaving frees a bay before a new truck arrives. Check the problem statement for tie-breaking rules, but that's the standard assumption.

Do I need to track which truck uses which bay?+

No. The problem asks for the minimum number of bays, not the assignment. You only need to know how many trucks overlap at peak. Tracking individual assignments wastes time and adds complexity.

Can I solve this in one pass without sorting?+

Not cleanly. You need to sort events by time first. One pass with a heap or sorted map works, but raw unsorted data doesn't. Sort, then sweep. O(n log n) is the expected complexity.

How hard is this for Amazon OA level?+

Medium. It's not a DP problem and it's not a graph problem. If you know the interval overlap pattern, it's a 15-minute solve. If you don't, you can waste 40 minutes guessing. The pattern recognition is everything.

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