[ INFO ]category: System Design · Unknown difficulty: medium freq: Must first seen: 2026-03-13
[MEDIUM][UNKNOWN][MUST]
$catproblem.md
Practice/Amazon/Design And Implement Amazon Locker System
Design And Implement Amazon Locker System
Object Oriented DesignMust
Problem
Design and implement a smart package locker system similar to those used by delivery services. The system manages a collection of lockers of various sizes where packages can be securely stored and retrieved by customers using one-time passwords (OTPs).
Your implementation should handle locker assignment based on package size, generate secure OTPs for package retrieval, enforce a 7-day expiration policy on stored packages, and manage the lifecycle of packages from delivery to pickup.
Requirements
Locker Management: Support three locker sizes (SMALL, MEDIUM, LARGE) with the ability to add lockers to the system
Package Assignment: Assign incoming packages to appropriate available lockers based on size matching
OTP Generation: Generate unique 6-digit OTP codes for each package assignment
Secure Retrieval: Allow package retrieval only with correct OTP validation
Expiration Policy: Automatically mark packages as expired after 7 days from assignment
Status Tracking: Track locker availability and package status throughout the system
Return Processing: Identify packages that need to be returned to sender due to expiration
Constraints
Locker IDs must be unique within the system
OTPs must be 6-digit codes (100000-999999)
Each locker can hold at most one package at a time
Packages can only be assigned to lockers of matching size
Once retrieved, the locker becomes immediately available for new packages
The system should handle multiple concurrent packages efficiently
Time complexity for retrieval operations should be O(1) or O(log n)