Skip to content
SparkTime, home
Off-Campus Placements With AI
Lessons
1 · Reality Check and Your Search Plan
2 · Building Credibility From Zero
3 · Resume and LinkedIn
4 · Finding Jobs Before the Crowd
5 · Applications and Referrals
6 · Online Assessments and DSA
7 · Company Research for Interviews
8 · Technical Interview Rounds
9 · Behavioral and HR Rounds
10 · Offers, Negotiation and Joining
11 · Rejection, Diagnosis and Momentum
Lesson 31 of 44

Lesson 31 · Technical Interview Rounds

Machine Coding and Low-Level Design for Freshers

Many product companies include a round where you design and build a small working system in 60 to 120 minutes: a parking lot, a cab booking service, a library system. Most freshers have never practised it. This article explains what these rounds evaluate, a time-boxed approach from requirements to running code, design principles that matter at this level, a complete small example, typical follow-up questions, and how to practise with AI as a demanding interviewer.

On this page

Key takeaways

  • A machine coding or low-level design round asks you to turn a vague business problem into a small, working, well-structured program in limited time.
  • Interviewers look at clarifying questions, clear entities and responsibilities, working core flows, handling of edge cases, readability and how easily the design extends.
  • Spend the first 10 to 15 minutes on requirements, entities and interfaces; build the core flow end to end first; then add edge cases and a demonstration.
  • At this level, a few principles matter most: single responsibility, composition over inheritance, programming to interfaces, and a design pattern only where it removes a real problem.
  • Expect follow-ups on extensibility and concurrency. Practise with AI as an interviewer that challenges your choices, and by rebuilding classic problems from scratch.

The interviewer says: "Design a parking lot. You have 90 minutes. I'd like working code at the end." Students who have only practised problem-solving tend to freeze. There is no single right answer, no hidden test cases and no constraint table. There are only questions: what kinds of vehicles? what sizes of spots? how is the fee calculated? what happens when the lot is full?

That openness is the point of the round. It simulates the actual job: take a loosely described need, ask the right questions, structure the code sensibly and deliver something that works. It is also very learnable, because the same handful of habits applies to every problem.

What you will learn

#
  • What machine coding and low-level design rounds are, and how they are evaluated.
  • A time-boxed approach from vague requirements to working code.
  • The design principles that matter most at entry level.
  • A complete small example, with its trade-offs.
  • Common follow-up questions on extensibility and concurrency.
  • How to practise, including with AI.

What the round is

#

Names differ: "machine coding", "low-level design" (LLD), "object-oriented design", "pair programming round". The common shape:

  • A problem described in a few sentences, from a familiar domain: a parking lot, an elevator, a library, a cab booking service, a food ordering system, a splitwise-style expense sharer, a rate limiter, a snake-and-ladder game, a hotel booking system.
  • 60 to 120 minutes.
  • Working code in your chosen language, sometimes on your own machine with your own editor, sometimes in a shared editor.
  • A discussion at the end, and often during.

Some companies want a full runnable program with a small demo; others care more about the class design and interfaces. Ask at the start: "Would you like a runnable demo, or is the class design and core logic the priority?"

What interviewers evaluate

#

Area

What they look for

Requirements

You ask clarifying questions and state assumptions instead of guessing silently

Modelling

Sensible entities (classes) with clear responsibilities and relationships

Working code

The core flows run end to end

Edge cases

Full lot, invalid input, duplicate actions, not found

Readability

Clear names, small methods, no giant "god class"

Extensibility

A new vehicle type or pricing rule does not mean rewriting everything

Communication

You explain trade-offs while building

A design with three well-built classes that work beats an ambitious design with twelve classes and nothing running.

A time-boxed approach (90 minutes)

#

Minutes

Step

Output

0 to 10

Clarify requirements

A short list of features in scope, out of scope and assumptions

10 to 20

Entities and interfaces

Class names, key fields, public methods, relationships

20 to 60

Core flow end to end

The main use case working, in the simplest way

60 to 75

Edge cases and one extension

Errors handled; one variation (for example a second pricing rule)

75 to 90

Demonstrate and discuss

A small driver or tests showing it works; trade-offs explained

Step 1: clarify

#

For a parking lot, questions might be:

  • What vehicle types and spot sizes? Can a small vehicle use a larger spot?
  • One floor or many? One entrance or several?
  • How is the fee calculated: per hour, per started hour, flat?
  • What happens when there is no suitable spot?
  • Do we need payment, reservations, multiple lots? (Usually: out of scope for now.)

Write the answers as a short list in a comment at the top of your file. It shows structure and keeps you honest about scope.

Step 2: entities and interfaces

#

Nouns in the requirements usually become classes; verbs become methods. For the parking lot: Spot, Vehicle (or just a plate and a size), Ticket, ParkingLot, and a pricing rule. Write their key fields and public methods before any logic.

Step 3: core flow first

#

Make "park a car, then unpark it and get a fee" work end to end, simply, before handling anything fancy. This is the brute-force-first habit from assessments, applied to design.

Steps 4 and 5: edge cases, then demonstrate

#

Then add: the lot is full; the same car parks twice; unparking a car that is not there. Finally, a short driver or a few tests that show the behaviour.

Principles that matter at this level

#

You do not need to recite every design principle. A few make the most difference:

  • Single responsibility. Each class has one job. The parking lot assigns spots; the pricing rule calculates fees. When requirements change, one class changes.
  • Composition over inheritance. Give a class a pricing object rather than creating HourlyParkingLot and FlatRateParkingLot subclasses.
  • Program to interfaces. Depend on "something that can calculate a fee", not on one specific pricing class, so a new rule can be swapped in.
  • Patterns only when they remove a real problem. A strategy for pricing makes sense, because pricing varies. A factory, a singleton and an observer added "because LLD rounds want patterns" make the code harder to follow. Interviewers notice pattern-stuffing.
  • Validate at the boundary. Check inputs where they enter (parking an already-parked car) and fail with a clear error.

For a clear, free explanation of common design patterns with examples, refactoring.guru is widely used.

A worked example: a parking lot

#

Assumptions written at the start: three spot sizes (small for bikes, medium for cars, large for buses); a vehicle may use a spot of its size or larger; the first free suitable spot is used, smallest first; the fee is charged per started hour by vehicle size; payment, floors and reservations are out of scope.

The program below is written in Python for brevity; in an interview, use the language you are most fluent in. It needs Python 3.10 or later.

Python
# File: parking_lot.py# A small machine-coding answer: a parking lot with spot sizes, tickets and# a pluggable pricing rule. Times are minutes since opening, so runs repeat exactly.import mathfrom dataclasses import dataclassfrom enum import Enumclass Size(Enum):    SMALL = 1   # bikes    MEDIUM = 2  # cars    LARGE = 3   # buses@dataclassclass Spot:    spot_id: str    size: Size    plate: str | None = None@dataclassclass Ticket:    ticket_id: int    plate: str    vehicle_size: Size    spot_id: str    entry_minute: intclass HourlyPricing:    """Charge per started hour, by vehicle size. Swap in another class to change pricing."""    RATES = {Size.SMALL: 10, Size.MEDIUM: 30, Size.LARGE: 60}  # rupees per hour    def fee(self, size, minutes):        return max(1, math.ceil(minutes / 60)) * self.RATES[size]class ParkingLot:    def __init__(self, spots, pricing):        self.spots = sorted(spots, key=lambda s: s.size.value)  # smallest first        self.pricing = pricing        self.active = {}  # plate -> Ticket        self.next_id = 1    def park(self, plate, size, minute):        if plate in self.active:            raise ValueError(f"{plate} is already parked")        for spot in self.spots:  # first free spot that is big enough            if spot.plate is None and spot.size.value >= size.value:                spot.plate = plate                ticket = Ticket(self.next_id, plate, size, spot.spot_id, minute)                self.next_id += 1                self.active[plate] = ticket                return ticket        return None  # lot full for this size    def unpark(self, plate, minute):        if plate not in self.active:            raise ValueError(f"{plate} is not parked here")        ticket = self.active.pop(plate)        spot = next(s for s in self.spots if s.spot_id == ticket.spot_id)        spot.plate = None        return self.pricing.fee(ticket.vehicle_size, minute - ticket.entry_minute)lot = ParkingLot([Spot("L1", Size.LARGE), Spot("M1", Size.MEDIUM),                  Spot("S1", Size.SMALL), Spot("M2", Size.MEDIUM)], HourlyPricing())for plate, size, minute in [("KA01-BIKE", Size.SMALL, 0), ("KA02", Size.MEDIUM, 5),                            ("KA03", Size.MEDIUM, 10), ("KA04", Size.MEDIUM, 12),                            ("KA05", Size.MEDIUM, 15)]:    t = lot.park(plate, size, minute)    print(f"park {plate:<9} -> {t.spot_id if t else 'FULL'}")try:    lot.park("KA02", Size.MEDIUM, 20)except ValueError as e:    print("error:", e)print("unpark KA01-BIKE after 61 min, fee:", lot.unpark("KA01-BIKE", 61))print("unpark KA03 after 90 min, fee:", lot.unpark("KA03", 100))print("park KA05 again ->", lot.park("KA05", Size.MEDIUM, 101).spot_id)
Code
park KA01-BIKE -> S1park KA02      -> M1park KA03      -> M2park KA04      -> L1park KA05      -> FULLerror: KA02 is already parkedunpark KA01-BIKE after 61 min, fee: 20unpark KA03 after 90 min, fee: 60park KA05 again -> M2

What to notice, and what you would say in the interview:

  • Responsibilities are separated. ParkingLot assigns and frees spots; HourlyPricing calculates fees. A weekend rate or a flat-rate pricing rule is a new class with a fee method, passed to the lot, with no change to ParkingLot.
  • The fee uses the vehicle's size, not the spot's. The car KA04 parked in a large spot because medium ones were full; charging it the bus rate would be unfair. That was a decision, and worth saying aloud.
  • Edge cases fail clearly: a car already parked, a car not parked, a full lot (park returns None).
  • The search is a simple loop. It is O(number of spots) per park. Fine for a few hundred spots; for a large lot you might keep a separate queue of free spots per size. Mentioning this, without building it, shows judgement.

Follow-up questions to expect

#

Interviewers often extend the problem to see how your design copes:

Follow-up

A good direction for the answer

"Add electric vehicle charging spots."

A spot attribute or type, and a matching rule; ideally no change to pricing or tickets

"Pricing differs on weekends."

Another pricing class, or a pricing rule that takes the date; the lot does not change

"Two cars arrive at the same moment at two entrances."

The spot assignment must be atomic: a lock around find-and-assign, or an atomic database update, so one spot is not given to two cars

"There are five floors."

A Floor class that holds spots, with the lot choosing across floors; or keep spots with a floor field

"How would you test this?"

Unit tests for pricing (boundaries such as exactly 60 and 61 minutes), for full lots, for double parking

"What would you change for a real system?"

Persist tickets in a database; handle payment failures; keep free-spot indexes; add audit logs

You do not have to build every follow-up. Explaining how your design would accommodate it is often what is wanted.

Practising

#

Rebuild classic problems from scratch

#

Pick six to eight classic problems and build each one in 90 minutes, timed, in your interview language: parking lot, library management, expense sharing, elevator, snake and ladder, a rate limiter, a hotel booking system, a food ordering flow. Then compare your design with a well-regarded reference implementation, and write down one thing to do differently.

Practise with AI as a demanding interviewer

#

You can ask an assistant to play the interviewer, including using your company research notes (article 27) to choose a problem in the company's domain:

Code
Act as an interviewer running a 90-minute machine coding round for an entry-levelengineer. Use a problem from [the company's domain, from my notes: e.g. payouts,delivery tracking]. Rules:- Give the problem in 3 or 4 sentences, deliberately leaving some things unclear.- Answer my clarifying questions briefly, as a product owner would.- When I share a class or method, ask ONE question about a design choice:  "why this over that?", "what if we need to add X?", or "what if two users do this  at the same time?"- Do not write code for me.- At the end, give a verdict on requirements, modelling, working code, edge cases,  readability and extensibility, and the single biggest improvement.

Then build in your own editor, sharing classes as you go. The questions train the explaining that the real round requires.

Common mistakes

#
  • No clarifying questions, then building the wrong thing.
  • Designing twelve classes and running out of time with nothing working.
  • One giant class that does everything.
  • Inheritance where composition fits (a subclass for every variation).
  • Adding patterns to look sophisticated.
  • Ignoring concurrency when asked, or not knowing what "atomic" means.

Exercises

#

Exercise 1

Clarifying questions

#

Write six clarifying questions for "Design a library management system", and mark which answers would change your class design most.

Exercise 2: Find the design problems

#

A candidate's design: one class LibrarySystem with 30 methods (adding books, issuing, returning, calculating fines, sending emails, printing reports); subclasses StudentLibrarySystem and FacultyLibrarySystem that differ only in fine rates and borrowing limits. Identify the problems and propose a better structure.

Exercise 3: Extend the parking lot

#

Using the example's design, describe the changes needed to (a) add a flat ₹50-per-visit rate for cars on Sundays, and (b) make spot assignment safe when two entrances call park at the same time. Say which classes change.

Exercise 4: One timed build

#

Choose a classic problem you have not built. Build it in 90 minutes using the time-boxed approach, with a short driver that demonstrates the core flow and two edge cases. Then ask an assistant to review it as an interviewer would, and write down the biggest improvement.

Show solutionHide solution
  1. Who borrows: students, faculty, both, with different limits? (Changes design: member types or borrowing policies.)
  2. How are books identified: by title, or by individual copies with their own IDs? (Changes design a lot: a Book versus BookCopy distinction.)
  3. What are the rules: maximum books, loan period, renewals?
  4. Are there fines for late returns, and how are they calculated? (Changes design: a fine policy, possibly a strategy.)
  5. Do we need reservations or waiting lists when all copies are out? (Adds an entity and a flow.)
  6. Is searching by author, title or subject required, and does it need to be fast?

The biggest modelling decisions are copies versus titles, member types and fine policies.

Exercise 2

Show solutionHide solution

Problems:

  • A god class. LibrarySystem has many unrelated responsibilities: inventory, loans, fines, notifications, reports.
  • Inheritance for variation. Two subclasses differing only in numbers duplicate structure; a third member type would mean a third subclass.
  • Hard to test and change. Changing the fine rule means editing a 30-method class.

Better: Catalogue (books and copies), LoanService (issue, return, limits), FinePolicy (an interface with implementations per member type, or one policy that reads rates from the member's type), Notifier (emails), ReportService (reports). Members have a type that refers to a borrowing policy (limits and loan period), so a new member type is data, not a new class.

Exercise 3

Show solutionHide solution

(a) Add a new pricing class, for example SundayFlatRateForCars, whose fee method checks the day and size: ₹50 for a car on Sunday, otherwise the hourly rule (it can hold an HourlyPricing and delegate to it). The fee method needs the date, so either pass the entry and exit times as dates instead of minutes, or pass the day. ParkingLot changes only in what it passes to the pricing object; it does not learn about Sundays.

(b) Make "find a free spot and assign it" atomic. In a single process, guard park (and unpark) with a lock so only one thread searches and assigns at a time. In a real system with a database, use an atomic update ("set the spot's plate where the plate is empty") and check that one row changed, or a transaction with the right isolation. Only ParkingLot changes.

Exercise 4

Show solutionHide solution

Check your build against the evaluation table:

  • Requirements written as a comment at the top, with assumptions.
  • Entities with one responsibility each.
  • The core flow working end to end, shown by the driver.
  • Two edge cases handled with clear errors.
  • One place where a change (a new type or rule) needs only a new class.
  • Finished within 90 minutes, or a note of where time went.

From the AI review, take the single biggest improvement and apply it in your next timed build, not by rewriting this one forever.

Where to go next

#

Keep reading

More in Career →
  • Guide · Career

    Interview Preparation and Mock Interviews with AI

  • Guide · Technology

    Heaps and Priority Queues

  • Course · Technology

    DSA From Zero to Job-Ready: A Practical Guide with Java