SDE Roadmap

Phase 4

Low Level Design

Class design and patterns. Practice before you read solutions.

Phase progress0%

Phase 4

Important

Low Level Design

Class design and patterns. Practice before you read solutions. · 3–4 weeks

Parking Lot

Must know
Beginner

Multi-floor lot, vehicle types, nearest slot, ticket + fee.

A parking-lot LLD is an object model for floors, slots, vehicles, tickets, and fees — not a database schema. You assign a free slot (often nearest), issue a ticket on entry, and compute a fee on exit by vehicle type. Strategy fits pricing; do not bury vehicle rules in a giant switch on the lot. The interview is class boundaries and relationships, then a simple assign/exit flow.

Requirements

  • Multiple floors and slot sizes
  • Bike / Car / Truck
  • Issue ticket on entry, fee on exit

Classes to identify

  • ParkingLot
  • Floor
  • Slot
  • Vehicle
  • Ticket
  • FeeStrategy

Relationships. Lot has Floors; Floor has Slots; Ticket references Vehicle and Slot.

Patterns

  • Strategy (pricing)
  • Singleton (lot, optional)

Practice prompt. Design a parking lot that assigns the nearest free slot and computes fees by vehicle type. Do not look at a full solution until you have a class diagram.

Elevator

Important
Intermediate

Requests from halls and cabins, direction, multiple elevators.

An elevator system takes hall and cabin requests and moves cars without randomly reversing mid-trip. State (idle, moving up/down, maintenance) plus a dispatch strategy for multiple cars is the usual design. Start with one car and SCAN-like direction, then add a controller that assigns requests. The hard part is request queues and direction, not drawing cables.

Requirements

  • Up/down requests
  • Do not reverse mid-trip without a reason
  • Optional: multiple cars

Classes to identify

  • Elevator
  • ElevatorController
  • Request
  • Direction
  • Door

Relationships. Controller assigns Request to an Elevator.

Patterns

  • State (moving/idle/maintenance)
  • Strategy (dispatch)

Practice prompt. Design an elevator controller. Start with one car, then extend to a bank of elevators.

Tic Tac Toe

Must know
Beginner

Board, players, win/draw detection, optional undo.

Tic-tac-toe is a Game that owns a Board and Players and applies Moves. Win detection should run from the last move (row/col/diag), not a full scan every time if you can avoid it. Design the board so N×N / K-in-a-row is a parameter, not a rewrite. Optional undo is a stack of moves. Keep UI out of the domain objects.

Requirements

  • 3x3 then NxN
  • Detect win on last move
  • Two players

Classes to identify

  • Board
  • Player
  • Game
  • Move

Relationships. Game has Board and Players; Move updates Board.

Patterns

  • Strategy (if you add bots)

Practice prompt. Implement a tic-tac-toe game that can later become N-in-a-row without rewriting everything.

Snake & Ladder

Important
Beginner

Board with snakes/ladders, dice, multiple players, win condition.

Snake and ladder is a turn-based Game: roll dice, move a Player along a Board, then jump if the cell is a snake or ladder. The board is data (start → end map), not if (position == 14). Decide exact-win vs bounce at the end. Multiple players are a list and a turn index. No design pattern is required — clear OOP is the bar.

Requirements

  • Configurable snakes and ladders
  • Turn-based players
  • Exact win or bounce

Classes to identify

  • Board
  • Cell
  • Dice
  • Player
  • Game

Relationships. Board maps start→end for snakes/ladders; Game moves Player.

Patterns

  • None required — clean OOP first

Practice prompt. Model the board as data, not a giant if-else of snake positions.

Library Management

Must know
Beginner

Search, borrow, return, fines, librarian vs member.

A library LLD separates Book (ISBN, title) from BookItem (physical copy with barcode). Members borrow items via Loans with due dates and fines; a Catalog searches by title/author/ISBN. Librarian vs member is a role, not a second copy of the whole model. The trap is treating every copy as the same Book object so you cannot track who has which copy.

Requirements

  • Search by title/author/ISBN
  • Borrow limits
  • Due dates and fines

Classes to identify

  • Library
  • Book
  • BookItem
  • Member
  • Loan
  • Catalog

Relationships. Book has many BookItems; Loan ties Member to BookItem.

Patterns

  • Singleton (catalog, optional)

Practice prompt. Separate Book (ISBN) from BookItem (physical copy).

Splitwise

Must know
Intermediate

Equal/exact/percent splits, balances, simplify debts.

Splitwise records an Expense paid by someone and Split among users (equal, exact, percent — Strategy). A BalanceSheet stores how much A owes B after many expenses. Get pairwise balances right before “simplify debts” (min cash-flow). Do not start from the graph algorithm; start from User, Expense, Split, and an invariant that splits sum to the total.

Requirements

  • Equal, exact, percent splits
  • Show balances
  • Optional: simplify debts

Classes to identify

  • User
  • Expense
  • Split
  • BalanceSheet

Relationships. Expense has Splits; BalanceSheet aggregates User pairs.

Patterns

  • Strategy (split types)

Practice prompt. Do not start with the simplify-debts algorithm. Get balances right first.

Vending Machine

Important
Intermediate

Select item, insert money, dispense, return change. Invalid states.

A vending machine is a State machine: idle, has money, dispensing, sold out, cancelled. Each action (insert coin, select, refund) is valid in some states only — that is the State pattern. Inventory holds items and prices; change is computed on success. The interview is “you cannot dispense with no money” encoded in types/states, not a pile of booleans.

Requirements

  • Idle → has money → dispense
  • Cancel and refund
  • Sold out

Classes to identify

  • VendingMachine
  • Inventory
  • Item
  • Money
  • State

Relationships. Machine has Inventory and current State.

Patterns

  • State

Practice prompt. Use the State pattern so each action is valid only in some states.

ATM

Important
Intermediate

Card, PIN, withdraw, balance, cash dispenser.

An ATM session authenticates a card (PIN via a BankService you mock), then withdraws or shows balance. CashDispenser hands out notes (often chain of denomination handlers). Treat the bank as an interface — the machine should not own accounts. State covers idle → card in → authenticated → eject. Cancel and errors must eject the card; that is part of the model.

Requirements

  • Authenticate
  • Withdraw with denomination mix
  • Eject card on cancel/error

Classes to identify

  • ATM
  • CardReader
  • CashDispenser
  • BankService
  • Session

Relationships. ATM talks to BankService; Session holds authenticated Card.

Patterns

  • State
  • Chain of Responsibility (dispenser)

Practice prompt. Treat the bank as an interface. You should be able to mock it in tests.

Car Rental

Important
Intermediate

Search cars, reserve, pickup/return, pricing, overlapping bookings.

Car rental is inventory of Vehicles at a Store plus Reservations that block a vehicle for a date range. The hard invariant is no overlapping bookings for the same car. Pricing is a Strategy by vehicle type or duration. User, Reservation, Bill are separate from the vehicle catalog. Model the interval explicitly; do not hope two bookings “probably” do not clash.

Requirements

  • Inventory by location
  • No double booking
  • Pricing by vehicle type

Classes to identify

  • Store
  • Vehicle
  • Reservation
  • User
  • Bill

Relationships. Store has Vehicles; Reservation blocks a Vehicle for a date range.

Patterns

  • Strategy (pricing)

Practice prompt. The hard part is overlapping date ranges. Model that explicitly.

Movie Ticket Booking

Must know
Advanced

Shows, seats, hold/lock, payment, concurrency.

Movie booking is Theatre → Screen → Show → Seats, plus a Booking that holds seats until payment or timeout. Two users must not confirm the same seat — that is the interview (lock/hold with expiry, then confirm). Pricing and payment are supporting pieces. Design the seat lock before UI. Concurrency is the problem; a class diagram without locks is incomplete.

Requirements

  • Browse shows
  • Hold seats for a few minutes
  • Confirm after payment

Classes to identify

  • Theatre
  • Screen
  • Show
  • Seat
  • Booking
  • Payment

Relationships. Show has Seats; Booking holds Seats until paid or expired.

Patterns

  • Strategy (pricing)
  • State (seat)

Practice prompt. Design the seat lock before you design the UI. Concurrency is the interview.

Chess

Good to know
Advanced

Pieces with different moves, turn taking, check/checkmate (keep scope honest).

Chess LLD is a Board of Pieces where each piece type implements its own legal moves (polymorphism/Strategy), plus turn taking. Do not build an engine or full checkmate search unless asked. Optional check detection is “does this move leave the king in attack.” Scope honestly: object model and move API, not Stockfish.

Requirements

  • Legal moves per piece
  • Turn order
  • Optional: check detection

Classes to identify

  • Board
  • Piece
  • Move
  • Game
  • Player

Relationships. Board holds Pieces; each Piece implements move rules.

Patterns

  • Strategy / polymorphism for piece moves

Practice prompt. Do not implement a chess engine. Get the object model and legal-move API right.

Logger

Important
Intermediate

Levels, multiple appenders, formatters. Chain of handlers.

A logger accepts a LogRecord (level + message), formats it, and fans out to Appenders (console, file). Levels filter; you add an appender without editing Logger (OCP). Chain of Responsibility or a list of appenders both work; Observer is the same idea. Singleton is optional and often overused. The test is: new destination, no rewrite of the log() method.

Requirements

  • DEBUG/INFO/WARN/ERROR
  • Console and file appenders
  • Configurable format

Classes to identify

  • Logger
  • LogRecord
  • Appender
  • Formatter

Relationships. Logger fans out LogRecords to Appenders.

Patterns

  • Chain of Responsibility
  • Singleton (optional)
  • Observer

Practice prompt. You should be able to add a new appender without changing Logger.