Design locker allocation service
AmazonSoftware Engineer · Technical ScreenLast updated
This question evaluates a candidate's understanding of stateful system design, resource allocation strategies, concurrency control, API and data modeling, and fault tolerance in the context of real-time locker assignment.
Amazon Locker OS provides a set of LockerIDs. Locker and package sizes are Small, Medium, and Large. Each locker may hold at most one package. Design the component that manages the set of lockers and returns the best-fitting LockerID when a courier arrives with a package. Clearly define "best fit" (e.g., prefer exact size; allow upsizing rules and their priority). Specify core operations (register lockers, mark available/occupied, assign, release on pickup, query status), data structures, and time/space complexity. Address concurrency (simultaneous couriers), idempotency and retries, race conditions, and fairness/starvation. Describe persistence and failure recovery. Provide APIs, schema, and pseudocode for assign(packageSize) and release(lockerId). Consider extensions such as reservations, per-location sharding, priorities/SLA tiers, and scaling.
Solution walkthrough is for members
Get the full walkthrough with reference code and complexity analysis, plus Kitty Coach at 300 messages a day. Hints, the code runner and community answers stay free.