"Design a parking lot" is the classic object-oriented design question. There is no single right answer; the interviewer watches how you clarify, model, and extend.
Ask about vehicle types (motorcycle, car, bus), spot sizes, multiple floors, payment, and whether you need entry/exit gates. Write the assumptions down.
ParkingLot holds floors and the entry/exit logic.Floor holds spots and can find a free spot for a vehicle size.Spot has a size and an optional current vehicle.Vehicle with subclasses or a size enum.Ticket records spot, vehicle, and entry time.park(vehicle) -> Ticket, leave(ticket) -> fee, and available_spots(size). Keep a free-spot set per size per floor so lookup is O(1) instead of scanning.
Pricing strategies (use a strategy interface), reservations, a display board showing free spots (observer pattern), and concurrency when two cars grab the same spot (lock per spot or atomic compare-and-set).
Jumping into code before agreeing on requirements, and putting all logic in one giant class. Keep responsibilities small. More interview prep at linkjob.ai.
Disclosure: I work on Linkjob AI.