Low-Level Design Interviews

A repeatable approach to object-oriented design interviews — clarifying requirements, finding entities, assigning responsibilities, applying patterns — with a fully worked parking lot design and a list of common problems.

Advanced 4 min readLesson 24 of 24

Low-level design (LLD) interviews — also called object-oriented design or machine-coding rounds — ask you to model a system as classes and implement its core logic in 45–90 minutes: a parking lot, an elevator, a library, a rate limiter, a chess game. Interviewers look for clear abstractions, sensible responsibilities, extensibility, and working code, not pattern name-dropping.

A repeatable approach

  1. Clarify requirements (5 min). Ask about scope: which features, which actors, scale, concurrency. Write down a short list of use cases and explicitly park the rest.
  2. Identify entities. Underline the nouns: they're candidate classes. Verbs become methods.
  3. Define relationships. Has-a vs is-a, multiplicities. Sketch a quick class diagram (UML).
  4. Assign responsibilities. Each class owns its data and the behaviour that uses it. Ask "who knows the information needed to do this?"
  5. Find what varies and put it behind interfaces: pricing, allocation strategy, notification channels. This is where patterns earn their place.
  6. Write the core code: models, the main service, the key algorithm. Use enums, immutable value objects, and clear names.
  7. Handle edge cases and concurrency: full lot, double booking, invalid states.
  8. Discuss extensions: how a new vehicle type, pricing rule or floor would be added.

Worked example: parking lot

Requirements (after clarifying): multiple floors with spots of sizes small/medium/large; vehicles are motorcycles, cars and trucks; a vehicle parks in the smallest free spot that fits; issue a ticket on entry; on exit compute the fee by duration and vehicle type; show free spots per floor. Multiple entry gates operate concurrently.

Entities: ParkingLot, Floor, Spot, Vehicle (+ type), Ticket, FeeCalculator / PricingStrategy, SpotAllocationStrategy.

1..*1..*issuesParkingLotpark() · leave()Floorspots by sizeSpotid · size · occupant«interface» SpotAllocator«interface» PricingStrategyTicketvehicle · spot · entry timeVehicleplate · type
enum SpotSize { SMALL, MEDIUM, LARGE }

enum VehicleType {
    MOTORCYCLE(SpotSize.SMALL), CAR(SpotSize.MEDIUM), TRUCK(SpotSize.LARGE);
    final SpotSize minSize;
    VehicleType(SpotSize minSize) { this.minSize = minSize; }
}

record Vehicle(String plate, VehicleType type) {}

final class Spot {
    final String id; final SpotSize size;
    private Vehicle occupant;
    Spot(String id, SpotSize size) { this.id = id; this.size = size; }
    boolean isFree() { return occupant == null; }
    boolean fits(Vehicle v) { return size.compareTo(v.type().minSize) >= 0; }
    void occupy(Vehicle v) { occupant = v; }
    void release() { occupant = null; }
}

record Ticket(String id, Vehicle vehicle, Spot spot, Instant entry) {}

interface SpotAllocator { Optional<Spot> find(List<Floor> floors, Vehicle v); }
interface PricingStrategy { long feeCents(Ticket t, Instant exit); }

final class Floor {
    final int number;
    final List<Spot> spots;
    Floor(int number, List<Spot> spots) { this.number = number; this.spots = spots; }
    long freeCount(SpotSize s) { return spots.stream().filter(x -> x.size == s && x.isFree()).count(); }
}

/** Smallest fitting spot, lowest floor first. */
final class SmallestFitAllocator implements SpotAllocator {
    public Optional<Spot> find(List<Floor> floors, Vehicle v) {
        for (SpotSize size : SpotSize.values()) {
            if (size.compareTo(v.type().minSize) < 0) continue;
            for (Floor f : floors)
                for (Spot s : f.spots)
                    if (s.size == size && s.isFree()) return Optional.of(s);
        }
        return Optional.empty();
    }
}

final class HourlyPricing implements PricingStrategy {
    private final Map<VehicleType, Long> centsPerHour;
    HourlyPricing(Map<VehicleType, Long> rates) { this.centsPerHour = rates; }
    public long feeCents(Ticket t, Instant exit) {
        long minutes = Duration.between(t.entry(), exit).toMinutes();
        long hours = Math.max(1, (minutes + 59) / 60);                  // round up, min 1 hour
        return hours * centsPerHour.get(t.vehicle().type());
    }
}

public final class ParkingLot {
    private final List<Floor> floors;
    private final SpotAllocator allocator;
    private final PricingStrategy pricing;
    private final Clock clock;
    private final Map<String, Ticket> active = new ConcurrentHashMap<>();

    public ParkingLot(List<Floor> floors, SpotAllocator a, PricingStrategy p, Clock clock) {
        this.floors = floors; this.allocator = a; this.pricing = p; this.clock = clock;
    }

    /** Synchronised so two gates can't grab the same spot. */
    public synchronized Ticket park(Vehicle v) {
        Spot spot = allocator.find(floors, v)
                .orElseThrow(() -> new IllegalStateException("Lot full for " + v.type()));
        spot.occupy(v);
        Ticket t = new Ticket(UUID.randomUUID().toString(), v, spot, clock.instant());
        active.put(t.id(), t);
        return t;
    }

    public synchronized long leave(String ticketId) {
        Ticket t = active.remove(ticketId);
        if (t == null) throw new IllegalArgumentException("Unknown or used ticket");
        t.spot().release();
        return pricing.feeCents(t, clock.instant());
    }
}

Design choices to say out loud:

  • Strategy for allocation and pricing: new rules (nearest-to-exit, weekend rates, EV spots) are new classes, not edits.
  • Enums encode the vehicle-to-spot-size rule in one place.
  • Injected clock makes fee calculation testable.
  • Concurrency: park and leave are synchronised; at higher throughput, lock per floor or keep per-size free-spot queues (ConcurrentLinkedQueue) for O(1) allocation. In a real deployment, the spot table in the database with a conditional update is the source of truth.
  • Extensions: payment methods (Strategy), display boards observing spot changes (Observer), entry/exit gates as separate classes, reservations.

Common LLD problems and their key ideas

ProblemKey abstractions and patterns
Elevator systemElevator state machine (State), request scheduling strategy (SCAN/LOOK), controller as mediator
Vending machineState pattern (idle → has money → dispensing), inventory, change-making
Library managementBook vs BookCopy, Member, Loan, fines (Strategy), reservations queue, notifications (Observer)
Tic-tac-toe / chessBoard, Piece hierarchy with move rules (polymorphism), Game state, move validation, undo (Command)
Snake and laddersBoard with jumps map, Dice (strategy for testing), turn loop
Splitwise / expense sharingExpense with split strategies (equal, exact, percent), balance sheet, debt simplification
Hotel / movie ticket bookingInventory per show/date, seat locking with timeouts, concurrency control, payment
LRU cacheHash map + doubly linked list; thread safety (Distributed cache)
Rate limiterToken bucket per key; strategy for algorithms (Rate limiting)
Logger / logging frameworkLevels, appenders (Strategy), chain of loggers (Chain of Responsibility), formatters, singleton/DI
Pub/sub or message queueTopics, subscribers (Observer), offsets, delivery threads
Ride sharing (core)Rider, Driver, Trip state machine, matching strategy, pricing strategy (surge)

What interviewers look for

Common mistakes: diving into code without requirements; a giant Manager class doing everything; using every pattern you know; ignoring concurrency when multiple actors share resources; running out of time before any working code exists.

Key takeaways
  • Clarify → entities → relationships → responsibilities → variation points → code → edge cases → extensions.
  • Put varying rules (pricing, allocation, scheduling) behind Strategy interfaces.
  • Model lifecycles with enums or the State pattern; use value objects.
  • Inject clocks and randomness; consider concurrency for shared resources.
  • Working, readable code for the core flow beats a perfect diagram.