Reject Bookings That Would Triple-Book a Loading Dock
Last updated: November 29, 2026
Quick Overview
Implement a loading dock calendar where book(start, end) succeeds unless the new half-open booking would cause some moment to be covered by three bookings at once; failed bookings are not stored.
Amazon
November 29, 20260
0
0 solved
Implement a loading dock calendar where book(start, end) succeeds unless the new half-open booking would cause some moment to be covered by three bookings at once; failed bookings are not stored.
An Amazon onsite design-flavored coding question about inbound freight scheduling, where a dock can serve two trucks at once. The interviewer checks that you track single and double-booked regions separately and only reject on a triple overlap.
What the Interviewer Expects
- Store all accepted bookings and the double-booked overlaps
- Reject if the new booking overlaps any double-booked region
- Otherwise add its overlaps with existing bookings to the double list
- Use the half-open overlap test max(starts) < min(ends)
- Discuss O(n) per call and a sweep alternative
Key Topics to Cover
How to Approach This
- Clarify input constraints and edge cases before writing code.
- Walk through your approach verbally and confirm with the interviewer before coding.
- Start with a brute force solution, then optimize. Mention time and space complexity.
- Test your solution with examples, including edge cases like empty input or duplicates.
- Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
- Generalize to allow at most k simultaneous bookings.
- How would a balanced tree of boundary counts improve performance?
- How would you support cancelling a booking?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
book(start, end) with start < end returns True and stores the booking if no point would be covered three times, else returns False and stores nothing. Up to about 1000 calls....
High-Level Design
Keep two lists:
booked: every accepted booking.overlaps: every region currently covered twice.
A new booking causes a triple overlap exactly when it intersects some region in overlaps. If...