System design · Low-level design
Design the classes, then prove they work
Low-level design is about classes and clean seams. Learn the few ideas behind every answer, read the classics, then write the code yourself.
- 6 foundations · 3 h
- 10 classic questions
- 14 coding exercises
- 1ClarifyPin down the use cases and what is out of scope before drawing a class.
- 2ModelNouns become classes, verbs become methods, and each class owns one job.
- 3ExtendShow where a new rule plugs in without editing what already works.
- 4TestWalk one scenario, then the edge cases, with a clock you can control.
1. Foundations
- 01 25 min
From Requirements to Classes
Every LLD answer starts the same way: read the requirements, pull out the nouns and verbs, and decide who owns which responsibility.
Foundation 1 - 02 30 min
SOLID, with Code That Breaks
Five principles that explain why a design survives the next requirement. Each one is shown as code that hurts, then code that doesn't.
Foundation 2 - 03 25 min
Swap Behaviour: Strategy and Decorator
Replace an if/else ladder with an object you can swap, and stack extra rules around it without editing the original.
Foundation 3 - 04 25 min
State Machines and Observers
Model an object that behaves differently in each phase as a state machine, and let other objects react to its changes without being wired into it.
Foundation 4 - 05 25 min
Factory, Builder, Singleton and Command
Four patterns that show up constantly, and the honest answer to when each one is overkill.
Foundation 5 - 06 20 min
The LLD Interview Playbook
A repeatable 45-minute structure, what interviewers actually score, and the mistakes that cost points.
Foundation 6
2. The classics, answered in full
- Medium 35 min
Parking Lot
Model entities, relationships, and pricing so new vehicle types or rules never force a rewrite.
Read the answer - Medium 35 min
Elevator System
Model cars, floors and requests as a state machine, then pick a dispatch strategy that keeps waits short and never starves a floor.
Read the answer - Easy 25 min
Vending Machine
A state machine in disguise: every coin, button press and refund has exactly one valid outcome in each state.
Read the answer - Medium 35 min
Library Management System
Separate the title from the copy, give each copy a small state machine, make fines a strategy, and make the last-copy borrow atomic.
Read the answer - Medium 35 min
Splitwise
Split bills four ways in integer cents with a fixed leftover rule, net the debts per pair, simplify them greedily, and keep settle-up race-free.
Read the answer - Easy 25 min
Snake and Ladder
A toy game with real design questions: one jump type for snakes and ladders, dice and the ending rule as strategies, and a layout check that stops jump loops.
Read the answer - Easy 25 min
Tic-Tac-Toe
Two classes with two jobs: a board that knows its lines and a game that knows the turn. Running totals check a win in O(1) on any size.
Read the answer - Medium 35 min
ATM
A state machine for the card and PIN flow, a chain of note handlers that backtracks on limited stock, and a withdrawal that never charges without paying.
Read the answer - Medium 35 min
Logging Framework
A tree of named loggers with inherited levels, appenders with their own thresholds and formats, and an async queue that forces a choice between dropping and blocking.
Read the answer - Medium 35 min
LRU Cache
A hash map plus a doubly linked list gives O(1) get and put. The design questions are the swappable eviction policy and why even a read needs the lock.
Read the answer
3. Code it yourself
Write the class in JavaScript or Python and submit against hidden tests. A wrong submission unlocks the step-by-step solution.
- Tic-Tac-ToeModel an N by N tic-tac-toe game so that a Game coordinates turns and results while a Board owns the grid, and every move is checked in constant time.Easy
- Parking LotBuild a multi-floor parking lot whose spot choice and pricing are separate, swappable policies you can change while it is running.Medium
- Rate LimiterPut fixed-window, sliding-window and token-bucket limiting behind one allow() method and switch between them at runtime.Medium
- Pricing RulesCompute a parking fee by stacking grace, cap, discount and minimum rules that each wrap the fee so far, in the order they were added.Medium
- Vending MachineModel a vending machine as a state machine so that every event in every state has exactly one defined outcome, and money is never lost or created.Medium
- Event BusBuild a publish/subscribe bus with exact and wildcard topics, where one event reaches each interested subscriber exactly once.Medium
- Text Editor with UndoBuild a text editor whose typing and deleting can be undone and redone, including groups of actions that undo as one step.Medium
- Eviction CacheBuild a fixed-size cache whose eviction rule (LRU, FIFO or LFU) is chosen by name, without any policy branching inside the cache.Medium
- ATMModel an ATM as a state machine with PIN lockout, and pay out exact amounts from limited stacks of notes without getting stuck.Medium
- Expense SplitterSplit bills equally, by exact amounts, by percent or by shares in integer cents, track who owes whom, and simplify the debts.Medium
- Logging FrameworkBuild a logger tree with inherited levels, appenders that each have their own threshold, and a swappable plain or JSON format.Medium
- Snake and LadderBuild a Snake and Ladder engine with jumps, three swappable ending rules, extra turns on a six and validation of bad boards, all driven by fixed dice.Medium
- Elevator SchedulerDrive one elevator car tick by tick with a swappable scheduling policy (LOOK sweeps or first-come-first-served) and exact call handling.Medium
- Library SystemModel books and copies, member tiers, a fair reservation queue with expiring holds, renewals and a tier-based fine policy, using only day numbers for time.Medium