Low-Level Design and Machine Coding Round: A Practical Guide
How to approach a machine coding or low-level design interview: a time-boxed workflow, the object-oriented principles interviewers check, a worked parking-lot example, common problems, and mistakes that lose points.
Machine coding and low-level design (LLD) rounds ask for something DSA practice doesn't: well-structured code for a small real system. They're common at Indian product companies (see what Flipkart, Razorpay and Swiggy ask) and appear in global loops for earlier-career roles.
What interviewers grade
- Requirements handling: did you ask before building?
- Modeling: are entities and relationships sensible?
- Extensibility: can a new rule or type be added without rewrites?
- Correctness: does it run on the provided cases?
- Code quality: naming, separation of concerns, no god classes.
- Edge cases and tests.
A time-boxed workflow (90 minutes)
| Time | Step |
|---|---|
| 0–10 | Clarify requirements; list use cases and assumptions |
| 10–20 | Entities, relationships, key interfaces (sketch, not code) |
| 20–60 | Implement the happy path end to end |
| 60–75 | Edge cases, validation, error handling |
| 75–90 | Demo/tests, README-style notes on extension points |
Worked example: parking lot
Requirements to confirm: multiple floors? vehicle types? pricing by hour? entry/exit tickets? concurrency?
Entities: ParkingLot, Floor, Slot, Vehicle (Car, Bike, Truck), Ticket, PricingStrategy.
class Vehicle:
def __init__(self, plate, kind): self.plate, self.kind = plate, kind
class Slot:
def __init__(self, sid, kind): self.sid, self.kind, self.vehicle = sid, kind, None
def is_free(self): return self.vehicle is None
class PricingStrategy:
def fee(self, hours): raise NotImplementedError
class HourlyPricing(PricingStrategy):
def __init__(self, rate): self.rate = rate
def fee(self, hours): return max(1, hours) * self.rate
class ParkingLot:
def __init__(self, floors, pricing): self.floors, self.pricing, self.tickets = floors, pricing, {}
def park(self, vehicle):
for slots in self.floors:
for s in slots:
if s.is_free() and s.kind == vehicle.kind:
s.vehicle = vehicle
self.tickets[vehicle.plate] = s
return s.sid
raise RuntimeError("no slot available")
def leave(self, plate, hours):
s = self.tickets.pop(plate)
s.vehicle = None
return self.pricing.fee(hours)The PricingStrategy is the extension point: weekend pricing or per-vehicle rates arrive without touching ParkingLot. State that out loud.
Frequently asked problems
Parking lot, elevator system, library management, tic-tac-toe, chess, splitwise, ATM, vending machine, BookMyShow, rate limiter, LRU cache, logging framework, notification service.
Principles to apply
- Single responsibility: a class has one reason to change.
- Open/closed: extend via new classes, not edits.
- Composition over inheritance for varying behavior.
- Depend on interfaces at extension points.
Mistakes that lose points
- Starting to code before requirements
- One 400-line class
- Patterns without a need (a Factory for one type)
- No way to run it
- Ignoring invalid input (unknown vehicle, double exit)
Common design patterns, and when they earn their place
| Pattern | Use it when | Example |
|---|---|---|
| Strategy | Behaviour varies and should be swappable | Pricing rules, matching algorithms |
| Factory | Object creation depends on a type | Creating vehicles or notifications by kind |
| Observer | Many parties react to an event | Notifying subscribers of price changes |
| State | Behaviour depends on state | Vending machine, order lifecycle |
| Singleton | Exactly one shared instance is needed | Configuration (use sparingly) |
| Decorator | Behaviour is layered on dynamically | Adding toppings or logging |
Use a pattern only when you can name the extension it makes easy. Patterns with no extension story look like over-engineering.
A second worked example: expense splitter
Requirements: users add expenses, split equally or by exact amounts or percentages, and see balances.
Entities: User, Expense, Split (Equal, Exact, Percent), BalanceSheet.
The extension point is the split type. Model it as an interface with a method that returns each participant's share, and validate in one place that shares sum to the total. Adding a new split type then needs one new class. State this aloud and show how a new type plugs in.
Concurrency and thread safety
Interviewers sometimes ask what changes with concurrent requests. Mention: shared mutable state, locks or atomic operations around critical sections (like assigning the last free slot), and idempotent operations. Even if you do not implement it, showing you know where the risk lies earns credit.
Testing in the round
You rarely have time for a full test suite, but a small harness shows professionalism:
- A main method that runs three or four scenarios
- A handful of assertions on edge cases
- Clear output so the reviewer can see behaviour at a glance
How reviewers read your code
Reviewers skim first. Make that skim easy:
- Meaningful names for classes and methods
- Small methods with one purpose
- Constants instead of magic numbers
- A short README or top-of-file comment on structure and assumptions
A 6-week practice plan
| Week | Problems |
|---|---|
| 1 | Parking lot, tic-tac-toe |
| 2 | Elevator, library management |
| 3 | Splitwise, vending machine |
| 4 | LRU cache, logging framework |
| 5 | Ride booking, BookMyShow |
| 6 | Timed mocks, review your own code for structure |
Time yourself. After each mock, ask: could I add a new rule without editing existing classes?
Related reading
Frequently asked questions
Was this article useful?
Bring backup into your next round.
Install InterviewPilot, upload your resume, and walk in with structured answers a keystroke away — visible to you and nobody else.
More from the blog
Can CoderPad Detect Cheating? What It Can and Can't See
CoderPad is a shared, browser-based editor where your interviewer watches you type. What it actually records (code playback, paste events, focus changes), what it can't see outside the tab, and why the live human is the real check.
Design a Chat Application: System Design Interview Walkthrough
How to answer the WhatsApp or Messenger system design question: WebSockets, message delivery and ordering, storage, presence, group chats, offline delivery and scaling to millions of connections.
Design a News Feed: System Design Interview Walkthrough
How to answer the news feed (Facebook, Instagram, Twitter timeline) question: fan-out on write vs read, the celebrity problem, feed ranking, storage, caching and the trade-offs interviewers want named.
Discussion
No comments yet. Been through an interview like this? Your experience could help the next candidate.