Low-Level Design Basics

LLD interviews ask you to model classes, relationships and interactions for systems like a parking lot or library.

Cheat sheet

  • ▸Steps: clarify requirements → identify entities → define relationships → define methods → apply patterns.
  • ▸Association: uses; Aggregation: HAS-A, independent lifetime; Composition: HAS-A, dependent lifetime.
  • ▸Use enums for fixed types (VehicleType, SpotSize).
  • ▸Keep classes small and cohesive; program to interfaces.
  • ▸Think about concurrency (two cars booking same spot).
  • ▸Classic problems: Parking Lot, Library, Elevator, Tic-Tac-Toe, BookMyShow, Splitwise.

Relationship types

TypeMeaningExample
AssociationUses / knowsTeacher — Student
AggregationHas-a, part can live aloneDepartment — Professor
CompositionHas-a, part dies with wholeHouse — Room
InheritanceIs-aCar — Vehicle

Visual

ParkingLot 1──* Floor 1──* Spot
Spot: id, size, isFree
Ticket: id, vehicle, spot, entryTime
Strategy: PricingStrategy.calc(ticket)

Top 10 campus interview questions

Quick quiz

1. House and Rooms (rooms die with house) is:

2. Pricing rules that vary should use:

3. Vending machine modes map well to:

4. Fixed set of vehicle types is best modelled with:

5. LLD focuses on: