Knowledge Guide
HomeOO & Low-Level DesignOO Design Problems

Design a Parking Lot — LLD Walkthrough

The classic LLD interview, done the way they grade it

"Design a parking lot" tests object modelling, not algorithms. The method: clarify requirements → identify entities → draw the class model → name the patterns → handle the tricky bits (here: concurrency). Below is that flow.

1. Requirements (clarify first)

UML class model: ParkingLot composed of Levels composed of ParkingSpots; an abstract Vehicle with Car/Motorcycle/Truck subclasses; a Ticket; Strategy and Factory noted
UML class model: ParkingLot composed of Levels composed of ParkingSpots; an abstract Vehicle with Car/Motorcycle/Truck subclasses; a Ticket; Strategy and Factory noted

2. The class model + the patterns it uses

abstract class Vehicle { abstract VehicleSize size(); }
class ParkingSpot { SpotType type; boolean free; boolean fits(Vehicle v){ /* size rule */ } }

class Level {
    private final List<ParkingSpot> spots;
    // concurrency: two cars must not claim the same spot
    synchronized Optional<ParkingSpot> assign(Vehicle v) {
        return spots.stream().filter(s -> s.free && s.fits(v)).findFirst()
                    .map(s -> { s.free = false; return s; });
    }
}

3. The tricky bit: concurrency

This is where senior candidates separate: two vehicles arriving at once must not be assigned the same spot — the lost-update race again (see Concurrency, and the Ticketmaster seat-lock). Guard the assignment (a lock per level, or an atomic compare-and-set on the spot's free flag). Don't lock the whole lot — that kills throughput; lock at the spot/level grain.

Pitfalls

Takeaways

🔨 Practice this

Reading isn't building. Build a Parking Lot → — implement this from an empty file in Go and Java with an O(1) per-size allocator, then write the concurrency test that fails the moment you drop the lock. That's the gap the interviewer probes.


Re-authored for this guide; UML class diagram hand-authored as SVG. Follows common LLD interview rubrics and GoF patterns. See also: Singleton, Strategy, SOLID, and (Concurrency) Race Conditions / (System Design) Ticketmaster.

🤖 Don't fully get this? Learn it with Claude

Stuck on Design a Parking Lot — LLD Walkthrough? Open Claude, copy a block below, and it'll teach you this exact concept — visually and interactively.

🎨 Explain it visually

Build the mental picture, not memorization.

I just read a lesson on **Design a Parking Lot — LLD Walkthrough** (OO & Low-Level Design) and want to truly understand it. Explain Design a Parking Lot — LLD Walkthrough from first principles using ONE vivid real-world analogy and a visual mental model — draw it as ASCII art or a clear step-by-step diagram — with a concrete example using real numbers. Then ask me one question to check I got the mental picture, and wait for my reply. If you're unsure or a claim isn't standard, say so and reason from first principles instead of guessing.
🤔 Walk me through it (interactive)

Socratic — adapts to where you're stuck.

Teach me **Design a Parking Lot — LLD Walkthrough** interactively. Ask me ONE guiding question at a time, wait for my answer, and adapt to my confusion — build the idea with me step by step instead of explaining it all at once. If you're unsure or a claim isn't standard, say so and reason from first principles instead of guessing.
🧪 Quiz me & fix my gaps

Active recall exposes what you missed.

Quiz me on **Design a Parking Lot — LLD Walkthrough** with 5 questions, easy to tricky, ONE at a time. Tell me if each answer is right; at the end, explain clearly what I got wrong and why. If you're unsure or a claim isn't standard, say so and reason from first principles instead of guessing.
🧠 Make it stick

Intuition + hook + flashcards for long-term memory.

Help me remember **Design a Parking Lot — LLD Walkthrough** for the long term: give the one-sentence intuition, a memorable hook/mnemonic, a tiny worked example, and 3 active-recall flashcards (Q -> A). If you're unsure or a claim isn't standard, say so and reason from first principles instead of guessing.

📝 My notes