Step 1: Requirements
Requirements
Questions to ask the interviewer
- How many floors and spots per floor?
- What vehicle types are supported — bike, car, truck?
- Is pricing time-based, flat, or tiered?
- Do we need real-time availability display at the entrance?
- Multiple entry/exit gates?
- Do we handle reservations or only walk-ins?
- Is there a monthly/subscription pass system?
Functional requirements
- A parking lot has multiple floors, each with multiple spots of different sizes.
- Vehicle types: Motorcycle, Car, Truck. Each needs a compatible spot size.
- Assign the nearest available spot of the right size when a vehicle enters.
- Track entry/exit time and calculate the fee based on a pricing strategy.
- Display available spots per floor on entry panels.
- Generate a parking ticket on entry; process payment on exit.
Non-functional requirements
- Thread-safe spot assignment (no double-booking).
- Extensible pricing (add new strategies without changing core logic).
- Easy to add new vehicle types.
Assumptions
- Single parking lot instance.
- No advance reservations (walk-in only).
- Payment is always successful (no payment gateway integration).