Low-level design (LLD) interview questions and machine coding rounds

Low-level design interview questions ask you to turn a short product brief, such as an expense splitter, a movie booking flow or an elevator, into classes, interfaces and working code within about an hour. Interviewers watch how you pin down requirements, where you draw boundaries between objects, which behavior you put behind an interface because it will change, and how you keep shared state correct when two users act at once. Machine coding rounds add a hard requirement: the code has to run, with a small demo or tests.

By Published 10 min read

What an LLD round looks like

Product companies, many Indian tech employers and some backend loops run a separate low-level design round next to data structures and system design. The high-level round draws services, databases and queues; the LLD round zooms into one service and asks for its object model and code. Formats vary. Some interviewers want a class diagram and method signatures on a whiteboard. Machine coding rounds give 60 to 120 minutes to write a runnable program in your own language, then review it with you. In both, the conversation matters as much as the result.

  1. Clarify and cut scopeList the use cases, confirm which are in scope, and ask about scale only where it changes the design (one process or many, in memory or persisted).
  2. Find the entitiesNouns from the brief become classes or value objects. Decide which own state and which are just data.
  3. Define behavior and boundariesPublic methods per class, the service that coordinates them, and the interfaces where behavior will vary.
  4. Handle state and concurrencyLifecycles as states with allowed transitions, and locks or atomic operations around shared inventory.
  5. Code, demo, extendWrite the core path first, show it running, then take the interviewer's extension request without rewriting everything.

Fundamentals questions

Concepts that come up before or during the design
QuestionWhat it testsWhat a strong answer shows
How is low-level design different from high-level design?FramingHLD decides components, data stores and how they talk across a network. LLD decides the classes, interfaces, methods and data structures inside one of those components.
Association, aggregation and composition: what is the difference?Class relationshipsAssociation is any link. Aggregation is a whole that holds parts that can live without it (a team and its players). Composition means the parts die with the whole (an order and its line items).
When do you make something an interface?AbstractionWhen there are, or will clearly be, several implementations chosen at run time: payment methods, pricing rules, split types. Not for a class with one implementation and no test need.
Entity or value object?ModellingAn entity has identity that persists as its fields change (a user, a booking). A value object is defined by its values and is best immutable (money, a seat number, a date range).
Where do you put the business rules?ResponsibilityWith the object that owns the data they check, or in a small domain service when a rule spans several entities. Not scattered across controllers.
Why use an enum for vehicle type, and when does it stop working?ExtensibilityAn enum is simple while types only differ in data. Once each type has its own behavior, polymorphic classes or a strategy keyed by type avoid switch statements spread everywhere.
How do you represent money?CorrectnessWith a decimal type or integer minor units plus a currency, never binary floating point, and with a clear rule for rounding leftovers.
How do SOLID principles show up in an LLD answer?Principles in practiceSmall classes with one reason to change, new behavior added as a new class rather than an edited switch, and high-level services depending on interfaces. SOLID principles covers each one in depth.
Concepts that come up before or during the design. Scroll sideways on a small screen.

Classic LLD problems and what each one probes

Intermediate questions: the brief, the core entities, and the decision the interviewer is really testing
ProblemCore entitiesThe decision they probe
Expense splitter (Splitwise style)User, Group, Expense, Split, LedgerSplit types as strategies (equal, exact, percent), rounding leftover cents, and simplifying who pays whom.
Movie or event ticket bookingShow, Screen, Seat, Hold, Booking, PaymentHolding seats with expiry and making check-and-claim atomic so two users never get one seat. The ticket booking system design covers the distributed version.
Elevator systemBuilding, Elevator, Request, ControllerThe scheduling strategy (nearest car, direction-aware), each car's state machine, and how requests from floors and cabins differ.
Vending machine or ATMMachine, State, Inventory, Coin or CardThe state pattern: which actions are legal in idle, has-money and dispensing states, and how refunds work on failure.
Parking lotLot, Level, Spot, Vehicle, TicketSpot allocation and pricing as replaceable policies; OOPs interview questions sketches the classes.
Tic-tac-toe, chess or snakes and laddersGame, Board, Player, Move, RulesSeparating rules from the board so the size or the rule set can change, and checking a win without scanning everything.
LRU cacheCache, Node, a map plus a linked listO(1) get and put, eviction order, and whether it must be thread safe.
In-process rate limiterLimiter, Bucket, ClockToken bucket versus sliding window, an injectable clock for tests, and per-key state cleanup. Distributed limits are in the rate limiter design.
Logger or notification serviceLogger, Handler, Channel, FormatterChain of responsibility or a list of handlers, adding a channel without editing the sender, and failure isolation.
Food order or ride lifecycleOrder, Driver, Restaurant, StatusAn explicit state machine with allowed transitions, and who is allowed to trigger each one.
Library or hotel managementItem, Copy, Member, Loan, ReservationThe difference between a title and a physical copy or room, and overlapping date ranges.
In-memory pub-sub queueTopic, Publisher, Subscriber, OffsetPer-subscriber offsets, slow consumers, and ordering within a topic.
Intermediate questions: the brief, the core entities, and the decision the interviewer is really testing. Scroll sideways on a small screen.

Worked example: split strategies and settling up

The expense splitter is a favorite because it is small enough to finish and has three real traps: rounding, validation of each split type, and a settle-up step. The version below puts each split type behind one interface, keeps balances in a ledger that always sums to zero, and settles greedily by matching the largest debtor with the largest creditor.

from abc import ABC, abstractmethod
from collections import defaultdict
from decimal import Decimal, ROUND_DOWN


class SplitStrategy(ABC):
    @abstractmethod
    def shares(self, amount: Decimal, users: list[str], params: list[Decimal]) -> dict[str, Decimal]: ...


class EqualSplit(SplitStrategy):
    def shares(self, amount, users, params):
        each = (amount / len(users)).quantize(Decimal("0.01"), rounding=ROUND_DOWN)
        result = {u: each for u in users}
        result[users[0]] += amount - each * len(users)   # the first user absorbs the leftover cent
        return result


class ExactSplit(SplitStrategy):
    def shares(self, amount, users, params):
        if sum(params) != amount:
            raise ValueError("exact amounts must add up to the total")
        return dict(zip(users, params))


class PercentSplit(SplitStrategy):
    def shares(self, amount, users, params):
        if sum(params) != 100:
            raise ValueError("percentages must add up to 100")
        result = {u: (amount * p / 100).quantize(Decimal("0.01")) for u, p in zip(users, params)}
        result[users[0]] += amount - sum(result.values())
        return result


class Ledger:
    def __init__(self):
        self.balance = defaultdict(Decimal)   # positive: is owed money, negative: owes

    def add_expense(self, payer, amount, users, strategy, params=()):
        amount = Decimal(amount)
        for user, share in strategy.shares(amount, users, [Decimal(p) for p in params]).items():
            self.balance[user] -= share
        self.balance[payer] += amount

    def settle_up(self):
        """Greedy: the biggest debtor pays the biggest creditor until all are even."""
        debtors = sorted((b, u) for u, b in self.balance.items() if b < 0)
        creditors = sorted(((b, u) for u, b in self.balance.items() if b > 0), reverse=True)
        payments, i, j = [], 0, 0
        while i < len(debtors) and j < len(creditors):
            (d, du), (c, cu) = debtors[i], creditors[j]
            pay = min(-d, c)
            payments.append((du, cu, pay))
            debtors[i], creditors[j] = (d + pay, du), (c - pay, cu)
            if debtors[i][0] == 0: i += 1
            if creditors[j][0] == 0: j += 1
        return payments


ledger = Ledger()
ledger.add_expense("asha", "120.00", ["asha", "ben", "chen"], EqualSplit())
ledger.add_expense("ben", "40.00", ["asha", "ben"], ExactSplit(), ["10.00", "30.00"])
ledger.add_expense("chen", "100.00", ["asha", "ben", "chen"], PercentSplit(), ["50", "25", "25"])
assert sum(ledger.balance.values()) == 0
for payer, payee, amount in ledger.settle_up():
    print(f"{payer} pays {payee} {amount}")
# ben pays chen 35.00
# ben pays asha 20.00
assert EqualSplit().shares(Decimal("100"), ["a", "b", "c"], []) == {
    "a": Decimal("33.34"), "b": Decimal("33.33"), "c": Decimal("33.33")}
Expense splitter: strategy per split type, Decimal for money, and a greedy settle-up. Prints the two payments that even out the group.
  • Why is the greedy settle-up not always minimal? Finding the fewest payments in general is a hard combinatorial problem. Greedy needs at most one payment fewer than the number of people with a non-zero balance, which most interviewers accept once you say so.
  • How would you add a "split by shares" type? A new strategy class. Nothing in the ledger changes, which is the point of the interface.
  • What would you persist? Expenses and their splits as the source of truth. Balances are derived and can be cached, then rebuilt if they ever disagree.

Senior questions: concurrency, change and testing

Experienced candidates get the same briefs with harder follow-ups. The most common is concurrency on shared inventory: seats, parking spots, stock, driver assignment. The sketch shows the core idea in one process, where the check and the claim happen under one lock and holds expire on their own.

import threading
import time


class SeatInventory:
    """Temporary seat holds for one show. Holds expire so abandoned carts free seats."""

    def __init__(self, hold_seconds=300, clock=time.monotonic):
        self.lock = threading.Lock()   # one lock per show; a database would use row locks
        self.hold_seconds = hold_seconds
        self.clock = clock
        self.booked = set()
        self.holds = {}                # seat -> (user, expires_at)

    def _free_for(self, seat, user, now):
        if seat in self.booked:
            return False
        holder = self.holds.get(seat)
        return holder is None or holder[1] <= now or holder[0] == user

    def hold(self, user, seats):
        with self.lock:                # check and claim must be one atomic step
            now = self.clock()
            if not all(self._free_for(s, user, now) for s in seats):
                return False
            for s in seats:
                self.holds[s] = (user, now + self.hold_seconds)
            return True

    def confirm(self, user, seats):
        with self.lock:
            now = self.clock()
            if any(self.holds.get(s, (None, 0))[0] != user or self.holds[s][1] <= now for s in seats):
                return False           # hold missing, taken by someone else, or expired
            for s in seats:
                del self.holds[s]
                self.booked.add(s)
            return True


# 50 users race for seat A1: exactly one hold succeeds.
inv = SeatInventory()
wins = []
threads = [threading.Thread(target=lambda u=u: inv.hold(u, ["A1"]) and wins.append(u)) for u in range(50)]
for t in threads: t.start()
for t in threads: t.join()
print("holders:", len(wins))                      # holders: 1

# Expiry with a fake clock: an abandoned hold frees the seat.
now = [0]
inv = SeatInventory(hold_seconds=300, clock=lambda: now[0])
assert inv.hold("ana", ["B1", "B2"])
assert not inv.hold("raj", ["B2"])
now[0] = 301
assert inv.hold("raj", ["B2"]) and inv.confirm("raj", ["B2"])
assert not inv.confirm("ana", ["B1", "B2"])        # ana's hold expired
print("expiry ok")
Seat holds for one show: atomic check-and-claim under a lock, expiring holds through an injectable clock, and a race of 50 threads where exactly one wins.
  • Why one lock per show and not one global lock? Shows do not share seats, so separate locks let unrelated bookings proceed in parallel. Per-seat locks add deadlock risk when a user holds several seats, unless you always lock them in a fixed order.
  • What changes when there are several app servers? The in-memory lock no longer covers everyone. Move the atomic step into the database (a conditional update or row lock) or a store with atomic operations, and keep the same class interface.
  • Why inject the clock? Expiry logic becomes testable without sleeping, and the same trick works for rate limiters and token lifetimes.
  • The interviewer adds a new requirement halfway. What do you do? Restate it, say which class absorbs it, and change as little as possible. If it breaks an assumption, say which one and refactor that part openly.
  • How do you test an LLD solution in a timed round? A short demo script or a handful of asserts covering the main path, one validation failure and one edge case such as rounding or expiry. That is usually enough to prove it runs.
  • When is your design over-engineered? When there are interfaces with one implementation, factories that build one thing, or patterns named for their own sake. Interviewers reward the smallest design that absorbs the stated changes.
  • How would you make an order state machine safe? Keep allowed transitions in one table, reject anything else with a clear error, record who triggered each change, and make repeated events idempotent.
  • Which language should you use? The one you are fastest in. Java, C++ and Python are all common; set up the project skeleton and build tool before the clock matters, since a broken build eats minutes. Maven interview questions covers the Java side.

Fictional example

Opening an elevator design without drawing classes yet
Interviewer
Design an elevator system for an office building.
Candidate
Before classes, a few questions. How many cars and floors, roughly? Do people press up or down in the hall and pick a floor inside, or choose the floor in the lobby? Is this the control software only, or do you want the simulation too? Assuming several cars, hall buttons and in-cabin buttons, I will model Elevator with its own state (idle, moving up, moving down, doors open) and a set of target floors, a Request that is either a hall call with a direction or a cabin call, and a Dispatcher that assigns hall calls through a SchedulingStrategy interface. I will start with nearest car moving in the right direction, and keep the strategy swappable because that is where the business will want changes, such as peak-hour modes. Then I will code the dispatcher and one car's state transitions and run a short simulation.

A two-week LLD practice plan

  • Days 1 to 3: review class relationships, value objects and the handful of patterns that carry LLD rounds (strategy, state, observer, factory). Design patterns interview questions has the definitions.
  • Days 4 to 9: solve one problem from the catalog per day under a 75-minute timer, in code, with a demo. Rotate between inventory problems (booking, parking), lifecycle problems (orders, vending) and rule problems (games, splits).
  • Days 10 and 11: redo two problems and add an extension the second time, such as a new split type or a peak-hour elevator mode, without rewriting the core.
  • Days 12 to 14: run mock rounds out loud. Practice the first five minutes of questions until they are automatic, then the concurrency follow-up.

Narrating while you design is a skill of its own, and it is hard to judge from memory. Natively, an AI interview assistant for Mac and Windows, transcribes a mock LLD round on your computer so you can see how long you spent on requirements and whether you explained each interface before coding it. In practice it can suggest answers live, read a problem statement or a class sketch from a screenshot, and help with code. Add your résumé and a job description (Pro or the free trial) and suggestions reflect the role; the transcript and notes are kept for review afterwards.

Questions people ask

What is asked in a low-level design interview?

A short brief such as an expense splitter, ticket booking, elevator, vending machine or parking lot, which you turn into classes, interfaces and code. Follow-ups cover concurrency, extensibility, testing and how the design changes with persistence.

How is a machine coding round different from an LLD round?

An LLD round may stop at a class diagram and method signatures. A machine coding round expects a runnable program within a fixed time, usually with a demo or tests, and then a review of the code with the interviewer.

Which design patterns matter most for LLD interviews?

Strategy for behavior that varies, state for lifecycles such as orders or vending machines, observer for notifications and factory for creating variants. Use a pattern only when the brief needs it.

How should I start an LLD answer?

Ask about use cases and scope for a few minutes, confirm what is in and out, then list entities and their responsibilities before drawing classes or writing code.

Where to go next

Practice with the same assistant you would use on a call: it listens, transcribes and suggests answers from your own resume and the job description.

Facts on this page were last checked on . Product details come from the Natively app itself; if something here is out of date, tell us at hello@heynatively.com.

Keep reading

Put it on your own machine.

A live-conversation assistant that runs locally. Your conversations stay on your machine.

macOS 12+ · Windows 10/11

© 2026 Natively AI Private Limited

Source-available under the Natively Personal Use Source License v1.0 · IP geolocation by DB-IP