PayPal's "Parking Lot" interview question is a classic low-level system design (LLD) problem often tagged for backend/web roles, focusing on object-oriented design rather than high-level scalability. It requires modeling a multi-level parking structure with various vehicle types and spots.
Design a parking lot system that manages vehicle entry, parking assignment, and exit across multiple levels. The system must support different vehicle types (e.g., motorcycle, car, truck), spot sizes (small, compact, large), and efficient spot allocation based on availability. Core operations include parking a vehicle (assigning the nearest available matching spot), unparking (releasing a spot and issuing a ticket/fee), and querying availability. Assume no payments, gates, or UI—focus on classes, relationships, and logic.[2][5]
From common implementations (e.g., Python class designs in interviews):
Park a Vehicle:
Input: park_vehicle("small") # or vehicle type/size Output: (spot_id=1, level=0) # Nearest available small spot on level 0
After multiple calls:
park_vehicle("small") → (1, 0) park_vehicle("small") → (2, 0) park_vehicle("large") → No available spots (if full)
Unpark a Vehicle:
Input: release_parking(spot_id=1, level_id=0) Output: "Released parking at spot 1, level 0" # Spot freed
Full Example Usage:
lot = ParkingLot(levels=5, spots_per_type=5, types=["small", "large"]) lot.park_vehicle("small") # Returns (1, 0) lot.release_parking(1, 0) # Frees spot lot.get_free_count("small") # Returns updated count, e.g., 4 initially per level
Simulates real flow: allocate → occupy → release → reallocate.[2]