A Framework for LLD Interviews
Most candidates who struggle in a low-level design interview don't lack knowledge. They lack a plan. They hear
"design a bike-share system", start typing a Bike class, realize ten minutes later that they don't know how
fees work, rewrite half of it, and run out of time before the interesting part.
A delivery framework is a fixed order of steps you follow for every LLD problem, with a rough time budget for each. It does three things for you. It makes sure you never code against rules you haven't settled. It gives the interviewer clear checkpoints where they can steer you. And it keeps time for the parts that carry the most signal: the core methods and the follow-up questions.
This post walks through the five steps, using one problem from start to finish so you can see what each step produces.
π― The five steps: requirements (what must it do?), entities (which nouns matter?), class design (who owns which state and methods?), implementation (the methods that hold the logic), and extensibility (how does the design absorb a change?). Each step's output is the next step's input.
The Five Steps at a Glance
| Step | Goal | What you produce | 45-min round | 90-min machine coding |
|---|---|---|---|---|
| 1. Requirements | Turn the prompt into rules | A numbered list + out of scope | ~5 min | ~10 min |
| 2. Entities | Find the objects that hold state or rules | A short list of names, and who owns whom | ~5 min | ~5 min |
| 3. Class design | Give each class its fields and methods | Skeletons with signatures, a quick sketch | ~10 min | ~15 min |
| 4. Implementation | Write the logic, happy path first | Working methods, then edge cases | ~15-20 min | ~45 min (plus a runnable driver) |
| 5. Extensibility | Show the design bends cleanly | Answers to "what if...?" with small sketches | ~5-10 min | ~10 min |
The numbers are a guide, not a stopwatch. What matters is the order, and that you never spend twenty minutes on step 1 or skip it entirely.
The running example is this prompt:
"Design a bike-share system. There are stations around the city. Riders take a bike from one station and return it to any other."
Step 1: Requirements
The prompt is vague on purpose. Your first job is to find the decisions it hides and get an answer for each. Good clarifying questions fall into a few kinds:
- Operations: what can each actor do? (rent, return, check availability)
- Rules and limits: how many bikes per rider, how fees work, station capacity.
- Errors: what happens when an operation can't succeed? (no bike, no free dock, rider already has a bike)
- Tie-breakers: when several choices are valid, which one wins? (which bike does a rider get?)
- Time and randomness: how does the code learn the time? Is anything random?
- Scope: payment, users, persistence, concurrency: in or out?
For the bike-share, the questions and answers might go like this:
You: Can a rider have more than one bike at a time?
Interviewer: No, one at a time.
You: How is the ride priced?
Interviewer: One dollar per started half hour, and every ride pays at least one half hour.
You: What if the rider reaches a station that is full?
Interviewer: The return fails, and they have to go to another station.
You: If a station has several bikes, which one does the rider get?
Interviewer: The one that has been docked longest. It spreads wear across the fleet.
You: Should I read the system clock?
Interviewer: No, pass the time in, in minutes.
Then write the answers down as rules. This is the most underrated part of the framework: a written list is something both of you can point at, and every later step refers back to it.
Bad:
- users can rent and return bikes
- there are fees
- stations have bikes
What the bad version costs you. None of these lines can be tested. "There are fees" doesn't say how much, and nothing says what happens when a station is full. You will make those decisions anyway, while coding, silently, and the interviewer may disagree with them after you've built on top of them.
Good:
1. A station has a fixed number of docks. Each dock holds at most one bike.
2. rent(rider, station, time): the rider gets the bike that has been docked longest at that station.
Fails if the station is empty or the rider already has a bike.
3. return_bike(rider, station, time): docks the bike and returns the fee in cents.
Fails if the rider has no bike or the station has no free dock.
4. Fee: 100 cents per started 30 minutes, minimum one block.
5. Time is passed in as minutes.
Out of scope: payment, user accounts, reservations, several threads.
Each rule is a sentence you could write a test for. The out-of-scope list protects you just as much: if the interviewer wants payments, they will say so now, not at minute 40.
π‘ Interview tip: read the final list back to the interviewer and ask "anything you'd change?". It takes 20 seconds and it is the cheapest bug fix of the whole round.
Step 2: Entities and Relationships
Next, find the objects. A quick way is to underline the nouns in your requirements: station, dock, bike, rider, rental, fee, time. Then filter. A noun becomes a class only if it holds state that changes or enforces a rule. Everything else is a field, an enum or a plain value.
Bad:
class Dock: ... # one per dock, each with an `occupied` flag
class Bike: ... # holds only an id
class Rider: ... # holds only an id
class Fee: ... # holds only a number
class Time: ... # holds only a number
class Station: ...
class Rental: ...
What the bad version costs you. Seven classes, and four of them do nothing. A Dock with an occupied flag
duplicates what the station already knows (how many bikes it holds versus its capacity). Every extra class is
something you have to write, explain and keep in sync, in a round where you have about fifteen minutes of coding.
Good:
- BikeShare is the entry point. It knows every station and every active rental, and it enforces the rules that span stations (one bike per rider).
- Station holds its capacity and the bikes docked there, in the order they arrived. It enforces "no bike to rent" and "no free dock".
- Rental records an active ride: who, which bike, where and when it started. It is what the fee is computed from.
- PricingStrategy computes the fee. It is its own piece because prices are the rule most likely to change.
Not classes, and why:
- Bike and rider are just ids (strings) for now. They hold no state the requirements care about. If a
follow-up adds e-bikes with a battery level,
Bikebecomes a class then. - Dock is not a class. A station only needs to know how many bikes it has and its capacity.
- Fee and time are integers (cents and minutes).
| Owner | Owns | How many |
|---|---|---|
| BikeShare | Station | many, by station id |
| BikeShare | Rental | at most one per rider, by rider id |
| BikeShare | PricingStrategy | one |
| Station | bike ids | up to its capacity, oldest first |
This is the step where you say the relationships out loud: BikeShare owns stations and rentals, a Rental
refers to a station, and BikeShare uses a pricing strategy. The
Class Relationships post covers how to sketch these quickly.
Step 3: Class Design
Now give each entity its fields and methods. Work top-down: start with the entry-point class (sometimes called the orchestrator), whose public methods are exactly the operations in your requirements. Then design each class it calls. Write skeletons only: signatures and fields, no bodies yet.
A common failure here is putting everything in the orchestrator.
Bad:
class BikeShare:
def __init__(self) -> None:
self.station_capacity: dict[str, int] = {}
self.station_bikes: dict[str, list[str]] = {}
self.rental_bike: dict[str, str] = {}
self.rental_start: dict[str, int] = {}
self.rental_station: dict[str, str] = {}
def rent(self, rider_id: str, station_id: str, now: int) -> str: ...
def return_bike(self, rider_id: str, station_id: str, now: int) -> int: ...
What the bad version costs you. Five parallel dictionaries that must be updated together. Forget one in a
single code path and the data disagrees with itself. There is nowhere to put a station rule, so every rule lands in
BikeShare, and the first follow-up makes it longer.
Good:
class BikeShare:
def __init__(self, pricing: PricingStrategy) -> None:
self.stations: dict[str, Station] = {}
self.rentals: dict[str, Rental] = {} # rider_id -> active rental
self.pricing = pricing
def add_station(self, station_id: str, capacity: int) -> None: ...
def add_bike(self, station_id: str, bike_id: str) -> bool: ...
def rent(self, rider_id: str, station_id: str, now: int) -> str: ...
def return_bike(self, rider_id: str, station_id: str, now: int) -> int: ...
class Station:
def __init__(self, station_id: str, capacity: int) -> None:
self.station_id = station_id
self.capacity = capacity
self.bikes: deque[str] = deque() # oldest docked bike on the left
def take_bike(self) -> str | None: ...
def dock(self, bike_id: str) -> bool: ...
@dataclass
class Rental:
rider_id: str
bike_id: str
start_station: str
start_time: int
class PricingStrategy(ABC):
@abstractmethod
def fee(self, rental: Rental, end_time: int) -> int: ...
Tie each piece to a requirement as you write it. rentals keyed by rider id makes "one bike per rider" a single
lookup (rule 2). The deque makes "docked longest" a popleft (rule 2 again). PricingStrategy exists because the
fee rule (rule 4) is the one the business will change. Then draw a quick sketch.
β οΈ Common mistake: writing method bodies during this step. Once you start coding
rent, you'll discover a missing field, change a class, and lose the overview. Finish all the skeletons first; they take five minutes and they are the design the interviewer grades.
Step 4: Implementation
With the skeletons agreed, write the methods that hold the logic. Two rules keep this step on track.
Happy path first. Write the version that works when everything goes right, end to end, before you handle any errors. That guarantees something complete exists if time gets tight.
Then the edge cases, one by one, from your requirements. Each "fails if..." in your list becomes a check. Say which error value you return before you write it.
A typical first draft mixes checks, state changes and arithmetic, and fails silently.
Bad:
def return_bike(self, rider_id: str, station_id: str, now: int) -> int:
rental = self.rentals.pop(rider_id) # KeyError if no rental
station = self.stations[station_id]
station.bikes.append(rental.bike_id) # ignores capacity
blocks = (now - rental.start_time) // 30 # rounds down: 59 minutes is one block
return blocks * 100
What the bad version costs you. Three bugs in five lines. A rider with no bike crashes the program. A full station silently goes over capacity. A 10-minute ride is free, which breaks rule 4. And the rental is removed before we know the return can succeed, so a failed return would lose the rental.
Good:
def return_bike(self, rider_id: str, station_id: str, now: int) -> int:
rental = self.rentals.get(rider_id)
station = self.stations.get(station_id)
if rental is None or station is None:
return -1
if not station.dock(rental.bike_id): # full station: rental stays active
return -1
del self.rentals[rider_id]
return self.pricing.fee(rental, now)
class HalfHourPricing(PricingStrategy):
def fee(self, rental: Rental, end_time: int) -> int:
minutes = end_time - rental.start_time
blocks = max(1, math.ceil(minutes / 30))
return blocks * 100
The checks come first and change nothing. State changes happen only once we know the operation succeeds, so a failure leaves everything as it was. And the fee lives in its own class, where it is easy to test.
rent follows the same shape:
def rent(self, rider_id: str, station_id: str, now: int) -> str:
station = self.stations.get(station_id)
if station is None or rider_id in self.rentals:
return ""
bike_id = station.take_bike() # oldest docked bike, or None
if bike_id is None:
return ""
self.rentals[rider_id] = Rental(rider_id, bike_id, station_id, now)
return bike_id
Verification
Finish the step by tracing one scenario through your code, out loud. It catches bugs before the interviewer does, and it shows you know what the code does rather than hoping.
| Call | State after | Returns |
|---|---|---|
add_station("A", 2), add_station("B", 1), add_bike("A", "b1"), add_bike("A", "b2") |
A: [b1, b2], B: [] | |
rent("ann", "A", 0) |
A: [b2], ann rides b1 | "b1" (docked longest) |
rent("ann", "A", 5) |
unchanged | "" (ann already has a bike) |
return_bike("ann", "B", 50) |
B: [b1], no rentals | 200 (50 min = 2 started half hours) |
return_bike("ann", "B", 60) |
unchanged | -1 (no active rental) |
π‘ Interview tip: pick a trace that hits at least one error path and one boundary (here, 50 minutes rounding up). A trace of only happy calls proves the least.
Step 5: Extensibility
In the last minutes, the interviewer changes the problem. These follow-ups are predictable. For bike-share, likely ones are e-bikes with a different price, a membership with free first half hours, a station that reports its availability to a display, or two riders renting at the same station at once.
Answer each one in the same three parts:
- What changes in the requirements.
- Which class absorbs it, and which classes stay untouched.
- A short code sketch of the new or changed piece.
For example, "members ride the first 30 minutes free":
class MemberPricing(PricingStrategy):
def __init__(self, base: PricingStrategy, members: set[str]) -> None:
self.base = base
self.members = members
def fee(self, rental: Rental, end_time: int) -> int:
full = self.base.fee(rental, end_time)
return max(0, full - 100) if rental.rider_id in self.members else full
"Only pricing changes. BikeShare, Station and Rental are untouched, because the fee rule already lives
behind PricingStrategy. That's the payoff of separating it in step 3."
When a follow-up does not fit your design, say so honestly and describe the refactor. "E-bikes need a battery
level, so Bike becomes a class with a kind field, and stations store Bike objects instead of ids. Rental and
pricing read rental.bike.kind." Interviewers value a clear refactor plan more than a design that pretended to
anticipate everything.
For concurrency ("two riders hit the same station at once"), name the shared state and the lock: "take_bike and
dock modify the station's deque, and rent checks then writes rentals. I'd give each station a lock and
guard rentals with another, always taking them in the same order." The
Concurrency Fundamentals post explains why.
Adjusting the Budget
The 45-minute budget is a default. Real rounds vary.
A 60-minute round gives you more room in step 4 and step 5. Use it for edge cases and a second follow-up, not for a longer requirements phase.
A 90-minute machine-coding round changes step 4 the most. You also need a small driver that reads commands and prints results, so wire it up right after the skeletons, with every command calling an empty method. Then fill the methods in one by one and run the program after each. The interview guide has more on this format.
When you fall behind, cut from the bottom, never from the top. Skip a third follow-up, trim the trace to three calls, and write one error path instead of five, saying out loud which ones you would add. Never skip the requirements or the class skeletons to "save time"; they are what keeps the code from needing a rewrite.
| You are at... | ...and the clock says | Do this |
|---|---|---|
| Still on requirements | 10 minutes in | Write the rules you have, list the open ones as assumptions, move on |
| Still on class design | 20 minutes in | Stop adding classes; code the orchestrator's main method now |
| Happy path not working | 35 minutes in | Drop the edge cases, make one full operation work, then trace it |
| Everything done | 30 minutes in | Ask for a follow-up yourself: "should I make this thread safe?" |
The Framework in an Interview
The framework is not a script to recite. It is a structure you make visible, so the interviewer always knows where you are. Three habits make it work.
Announce each step. One sentence is enough: "I have the requirements. Next I'll list the entities." It gives the interviewer a natural moment to say "looks good" or "wait, what about...".
Check in at the boundaries. The end of step 1 and the end of step 3 are the two points where a correction is cheap. After step 3 it starts costing code.
Follow the interviewer's lead. If they jump ahead ("let's assume the classes and see the code for rent"),
go. The framework is your default, not a rule. If they dig into one area, spend the time there and shorten the
others.
Here is what the end of step 3 sounds like:
You: "So
BikeShareis the entry point withrentandreturn_bike. EachStationkeeps its bikes in a queue so the oldest one goes first,Rentalrecords the active ride, and the fee sits behindPricingStrategybecause prices change. Bikes and riders are just ids for now. Does this match what you had in mind before I writerent?"
In four sentences you have summarized the design, justified the one abstraction, flagged a simplification, and asked for a cheap correction.
Summary
- Follow the same five steps for every problem: requirements, entities, class design, implementation, extensibility.
- Requirements end as a numbered list of testable rules plus an out-of-scope list. Read it back.
- A noun becomes a class only if it holds changing state or enforces a rule; the rest are fields, ids and enums.
- Design top-down from the entry point, skeletons only, and tie each field and method to a rule.
- Implement the happy path first, then each error case from your list; check before you change state. Finish with a trace that hits an error and a boundary.
- Answer follow-ups as: what changes, which class absorbs it, a short sketch.
- Budget roughly 5 / 5 / 10 / 15-20 / 5-10 minutes in a 45-minute round. When behind, cut from the end, never the start.