Before you start
Parking Lot is the most-asked design interview problem in the world. Every major product company has asked it. It's small enough to finish in an interview, big enough to reveal design skill.
Signals to spot
Two design signals are baked into the requirements. See if you can spot them before reading further.
Signal 1: "Adding a new vehicle type shouldn't rewrite existing code."
Signal 2: "Changing the fee rules should touch one place."
Both point at patterns from modules 1-3. Which ones?
Write your answer in design.md before implementing.
What separates a strong answer from a weak one
Weak: hardcodes vehicle types with if vtype == "bike": ... in three places (park, fit, fee). Passes the
tests. Fails the interviewer's follow-up questions.
Strong: builds a per-vehicle-type object that owns its own spot-fit list and its own fee rate. Adding an "electric-car" is one new class + one registration. The test verifies this.
The tests can't tell these two apart — both pass on
behavior. That's why design.md matters. Your
reasoning is what an interviewer will judge.
The rules question
"No spot holds two vehicles" sounds trivial. Then how do you handle:
- A caller passes a ticket_id that doesn't exist. Do you crash? Silently do nothing? Raise an explicit error?
- The same ticket_id gets unparked twice. Second call — what happens?
The tests pin these to raises ValueError. Your
design.md should say WHERE this rule is enforced
(e.g., "the active tickets dict is checked on every
unpark; missing key raises").
Signals to look for in every design problem going forward
Read requirements with these questions in mind:
- What changes over time? (State signal.)
- What gets added or removed as the system grows? (Factory / Registry / Strategy signal.)
- What must always be true? (A rule → where do you enforce it?)
- What algorithm has multiple valid versions? (Strategy signal.)
- What tree-shaped data appears? (Composite signal.)
Every problem in this module can be answered by walking this checklist and picking the patterns that fire.