Skip to content
Preptima
hardDesignCodingMidSeniorStaff

Design a parking lot system — you have 90 minutes, working code at the end.

In a parking lot machine coding round, scope one deterministic flow of park, unpark and charge, model Vehicle, Slot, Level, Ticket and a ParkingLot facade, then push slot allocation and pricing behind strategy interfaces so review-time variants are configuration rather than surgery.

6 min readUpdated 2026-08-15

Answer

Short answer

For a parking lot machine coding round, build one running end-to-end flow before adding features: park a vehicle, allocate a slot, issue a ticket, unpark, and compute the fee. The design should separate slot allocation and pricing behind strategy interfaces so variants such as nearest slot, monthly pass, or slab pricing add classes rather than if chains. Say what is out of scope early so the interviewer can grade working code, not imagined architecture.

Was this answer helpful?

Likely follow-ups

  • Two cars request the last available slot at the same instant — where exactly is your lock, and what is its granularity?
  • How would you support a monthly pass holder who parks free, without adding an if-branch to the pricing code?
  • The lot now spans ten levels and slot lookup is the bottleneck — what data structure replaces your linear scan?
  • How would you persist and rebuild lot state after a restart without leaking JPA annotations into your domain model?

Related questions

Further reading