Low-level design round

Design a Parking Lot

An AI interviewer asks you this problem out loud and pushes on your answers. You talk and draw through the round.

When it ends, you get a written letter and a scored report.

This round needs a laptop.

What the interviewer listens for

A low-level design round has five steps. Most candidates jump to the third.

  1. Requirements. Agree what the lot is before you name a class: floors, spot sizes, gates, and what happens on entry and on exit. Say what you are leaving out.
  2. Entities. Pull the nouns out of the requirements. Pick the one class that runs the flow.
  3. Class design. Give each class its data and a few methods. A spot's size and state are data on the spot.
  4. Implementation. Trace one car in and one car out. Then take the hard case below.
  5. Extensibility. The interviewer adds a requirement. Say where the change goes. Do not redraw the board.
Class diagram for a parking lot: ParkingLot, Floor, ParkingSpot, Gate, Vehicle and Ticket, with interfaces for spot assignment, pricing and payment.
The board at the end of the round. Swipe sideways to see the rest.

The case most answers miss

Two cars reach two entry gates at the same moment. One medium spot is free. If each gate first checks the spot and then takes it, both gates print a ticket for the same spot.

The fix is one step on the spot that checks and takes together. The first gate gets yes. The second gets no and looks for another spot. If none fits, it prints no ticket.

The ParkingSpot class with a tryClaim method that checks the state and marks the spot taken in one step.
One step on the spot, not a lock around the whole lot. Swipe sideways to see the rest.

Two follow-ups to answer out loud

  • How would you add charging spots billed per kilowatt-hour without editing Ticket or ParkingSpot?
  • How would you let a driver book a spot in advance?

Say your answers out loud. In the round, the interviewer pushes back on them.

Design a Parking Lot · Rehears