Skip to content
We areTOP 1%

Design a parking lot system

MediumConceptClassic LLD Problems
Track your progress
First attempt
Re-solve after a few days
Final pass before interviews

Answer

Model a multi-floor lot that issues a ticket on entry, assigns a suitable spot, and charges on exit. Key requirements are several vehicle and spot sizes, multiple entry and exit gates, and a configurable fee model.

  • Core classes: ParkingLot, Floor, ParkingSpot with a SpotType enum, Vehicle with a VehicleType enum, Ticket, EntryGate, ExitGate and Payment.
  • Patterns: a SpotAllocationStrategy (nearest first, or fill by floor) and a FeeStrategy (hourly or flat) keep policies replaceable; a factory can create vehicles.
  • Concurrency: two gates may try to claim the same spot, so assignment must be atomic, for example by locking per floor or using compare-and-set on the spot.
  • Keep free spots of each type in a set or queue for O(1) allocation.

More in Classic LLD Problems

Classic LLD Problems questions
#ProblemPlatformDifficultyOpen1st1st Visit2nd2nd VisitRevRevise
1Design a parking lot system
MediumConcept
ConceptMedium Read the answer to Design a parking lot system
2Design a vending machine
MediumConcept
ConceptMedium Read the answer to Design a vending machine
3Design an elevator system
HardConcept
ConceptHard Read the answer to Design an elevator system
4Design a movie ticket booking system
HardConcept
ConceptHard Read the answer to Design a movie ticket booking system

Sign in to track your progress

Your checkboxes, streak and activity heatmap are saved to your account and sync across devices. It is free.
Sign in with email

New here? Create an account