Library
27 min read

Design a parking lot

Fifty minutes into the round, your code works. A car comes in, gets a spot, and pays on the way out. Then the interviewer says: "Weekends are a flat ₹150 a day now. Show me what changes."

If the honest answer is "most of it", the round is lost, and it was lost in minute ten, when you chose your classes. The parking lot is the most common first LLD question because it is small enough to finish and still has three decisions that separate a working answer from a good one: which spot a car gets, what happens when two gates ask at once, and what the fee method is allowed to know.

The picture to keep
The cloakroom token

A cloakroom does not care what your coat is made of. It cares whether it fits on a hook or needs the big rail, which hook is free, and how long you left it. The token is the only thing that connects the coat going in with the coat coming out. A parking lot is the same machine with bigger coats.

In one line: Hand something in, get a token, hand the token back. Everything else is two rules you should expect to change: where it goes, and what it costs.

What this round expects#

LLD rounds come in two shapes, and how much code you write depends on which one you are in. Ask at the start if nobody tells you.

Design round on a whiteboardMachine coding round
TimeUsually 45 to 60 minutesUsually 90 minutes to 2 hours
What you produceThe class diagram, the key interfaces, one flow walked through, the one hard method in code or pseudocodeCode that compiles and runs, with a small demo at the bottom. In memory storage, no UI
What gets scoredWhere you drew the lines between classes, and whether you can defend each oneThe same, plus whether it runs, whether it reads well, and how fast a follow up goes in
On this pageSteps 1 and 2, then Change itAll of it. The code in Step 3 is the whole program, about 130 lines

Either way, the order of work is the same, and it is the order of this page: agree the requirements, find the objects, draw how they connect, then write code from the top down.

Finished this one?Mark it complete to track your progress through Low level design.