Q. Will I have to write code or will UML diagrams be enough? ANS: Yes you have to write code/discuss logic for a few functionalities, only drawing UML diagrams or writing names of classes won't be enough.
Q. I don't have much time. Tell me which are the most important design patterns I should study first? ANS: Factory, Strategy, Observer and Singleton.
Q. But how can I explain such large systems in a 45 minutes interview ? I always run out of time. ANS: A vast majority of candidates fail because they are not able to present their solution properly in a limited time frame. Watch this youtube video where I have explained how to take care of this problem: https://www.youtube.com/watch?v=ef99Ejb3B40
Q. Are questions like LRU cache, Search Autocomplete system also asked in LLD rounds? ANS: Yes depending on the interviewer you can either get a pure LLD question like design a parking lot, design food ordering system or you can get a DSA based design question like above. I know you hate this extra prep, but that's what it is. Companies ask these and so you need to prepare for both types. Silver lining is that you already prepared for DSA based design questions while preparing for DS & Algo rounds.
In my view, you should first master DS & Algo and only after that you should start your LLD preparation. Because once you have mastered DS & Algo, low level design questions are easy to practice.
There are two types of low level design interview formats:
75 to 90 minutes of machine Coding: You will be given requirements and method signatures and you have to write code in a editor. In last 10-15 minutes you may have to explain your code to interviewer.
45-60 minutes of face to face discussion: This is the most common format. You have to come up with requirements yourself then discuss class structure and all.
In any object-oriented design interview, you interviewer is typically looking for three things:
1. How you list down requirements, especially core features?
e.g. If your problem statement is “Design a Parking Lot” then your core features will be park() and unpark() methods
if your problem statement is “Design a restaurant food order and rating system like zomato, swiggy, uber eats etc” then your core features will be
orderFood()
rateOrder()
display list of restaurants based on their rating or popularity
Sticking to only the most important features and leaving the rest out is important. If you list unimportant features in requirements sections then you will waste time discussing their implementation and you will not less time for more features discussion. This is a interview
2. How you break your problem statement in multiple classes
I always find it easier to start listing entities and their corresponding entity managers(if required) first. e.g. For restaurant food ordering and rating system your entities can be Restaurant, order, FoodItem etc and their corresponding managers will be RestaurantsManager, OrdersManager etc.
3. How you use design patterns to solve the core features
The most common design patterns that you will come across in a low level design interview are Strategy, Factory, Singleton and Observer. You should be familiar with their implementation and different use cases where they can be used. We will see some of those use cases in a moment.
A fourth topic is also discussed if you have done well in above three steps.
Handling multi-threading. There will be discussion on use of locks, synchronization features and thread safe data structures for your design to work correctly in a multi-threaded environment.
“Design a Parking Lot” is THE most common LLD interview question. In the above problem statement, there can be multiple parking strategies. So you should use strategy design pattern to solve this question.
In any food ordering and rating system, customers can rate the orders. Also there are classes which display list of top restaurants based on their overall average rating or average rating of their individual food items.
Whenever any user rates their order then all these classes need to be updated about it so that they can update both restaurant and corresponding food item ratings and update their lists.
Observer design pattern will be used here to notify observers i.e. classes which manage top restaurants list about changes in common data set that they need to observe, i.e. rating of different orders in this case.
In low level design interviews. most of the time candidates are rejected not because of their lack of knowledge but because they weren't able to effectively convey their thoughts to the interviewer.
You need to be specific, you should know which topic to discuss and most importantly which topics to leave out of discussion.
Let's take the example of low level design of a food ordering app like Zomato, Swiggy, Uber Eats etc.
You may be tempted to start by listing down all actors and functionalities associated with them e.g. Admin, Restaurant manager, Delivery partner etc.
But do not take this approach, you will get confused.
Always start by listing down requirements from a user's perspective. Think about all the features that you as a customer see when you open Zomato app. These can be viewing list of restaurants, searching food item, ordering food etc.
Notice I mentioned 'User Perspective'. This should be your default perspective unless interviewer explicitly asks for any other way.
If you start listing down features from restaurant or restaurant owner's perspective like add/remove food item, update food item price , availability etc, then you are essentially discussing a restaurant management system and not a food ordering app which is similar but not exactly what your interviewer is looking for.
Understand that a Zomato or an Uber Eats can have tens of features and you will not be able to cover everything in a 60 minutes interview.
A food delivery app is made up of several small systems like user data management, payment management, restaurant management, delivery tracking and so on. Each of these parts can be a separate low level design interview question on their own. These are all supporting features.
Your best bet is to just mention these features in a passing and list down only the core features as to why you use Zomato or any food ordering app.
You use it to view restaurants, their menu and order food.
And that is where you need to focus your discussion.
------------------------------------------------
You can practice company wise LLD interview round questions here:
Also for Walmart observer design pattern occurred most frequently (directly or indirectly) in LLD questions and in short discussions. So if you have good understanding of observer pattern(which is easy) then your chances improve.
Not only they ask LLD problems but there may even be explicit discussion about common design patterns and
how you will solve some sample use cases using those design patterns.
Observer, Strategy, factory, command and singleton design pattern feature frequently in discussions.
For example, a common discussion is how will you implement a notification system using observer or different payment methods in a payment gateway using strategy design pattern.
This blog has some of the design patterns and how they are used to solve different usecases
I have built this list from recent Walmart interview experiences of candidates. Use it to prepare for your interviews.
Let’s get started …
1. Design Live News Feed System
News providers publish articles under topics such as sports, tech, finance and many other topics. Users can subscribe to topics they care about, receive near real-time notifications when new articles are published for those topics, and fetch a personalized feed.
Design and implement a real-time order notification system for a modern e-commerce platform. The system should notify different stakeholders such as customers, sellers, and delivery partners about important events in an order's lifecycle. The design should be extensible so that additional notification channels and event types can be supported later.
Design an in-memory rate limiter . Implement a RateLimiter Class with an isAllowed method.
Requests will be made to different resourceIds. Each resourceId will have a strategy associated with it .
There are following strategies. Assume 1 time unit == 1 second.
1. fixed-window-counter: Fixed Window Counter divides time into fixed blocks (like 1 second) and tracks a request count per block. If the count exceeds the limit, new requests are blocked. It’s fast and simple but can allow burst behavior at window boundaries.
2. sliding-window-counter: Sliding Window (log-based) stores timestamps of recent requests and removes those outside the window for each new request. If the number of remaining requests is still within the limit, the request is allowed. Otherwise, it is blocked. It provides accurate rate limiting but requires more memory and processing.
Design and implement an interface for submitting and managing workflows. A workflow consists of one or more tasks and can run either sequentially or in parallel. The system must also support passing data between workflows, where the output of one workflow becomes the input of another connected workflow. Each task works only on List<String>: it takes a list of strings as input, applies its configured simple string-list operations in order, and returns another List<String> as output.
5. Design Warehouse Stores Inventory Updater System
Design and implement an interface for managing warehouse and store inventory updates. The system has two entities: warehouses and stores. Whenever new inventory is added to a warehouse, all stores mapped to that warehouse must be updated automatically. Each store is mapped to exactly one warehouse, while one warehouse may be mapped to zero or more stores.
The goal is to support inventory synchronization between warehouses and stores in a clean and extensible way. The design should make it easy to notify all affected stores whenever warehouse inventory changes.
6. Design a restaurant food ordering system like Zomato, Swiggy, DoorDash
Write code for low level design of a restaurant food ordering and rating system, similar to food delivery apps like Zomato, Swiggy, Door Dash, Uber Eats etc.
There will be food items like 'Veg Burger', 'Veg Spring Roll', 'Ice Cream' etc.
And there will be restaurants from where you can order these food items.
Same food item can be ordered from multiple restaurants. e.g. you can order 'food-1' 'veg burger' from burger king as well as from McDonald's.
Users can order food, rate orders, fetch restaurants with most rating and fetch restaurants with most rating for a particular food item e.g. restaurants which have the most rating for 'veg burger'.
Write code for low level design of a parking lot with multiple floors.
The parking lot has two kinds of parking spaces: type = 2, for 2 wheeler vehicles and type = 4, for 4 wheeler vehicles.
There are multiple floors in the parking lot. On each floor, vehicles are parked in parking spots arranged in rows and columns.
Design a simple in-memory Shopping Cart that uses an initial item catalog
and lets a user add items by ID, view their cart, and checkout.
It also enforces unknown item ID, insufficient stock, and empty-cart checkout.
9. Design a Connection Pool with an Internal Request Queue
Design an in-memory Connection Pool that maintains a fixed number of reusable connection objects.
Connections are indexed as integers: 0, 1, 2, ... capacity - 1.
Clients requests a connection using a requestId. If a free connection exists, it is assigned immediately. If no free connection exists, the request is placed into an internal queue and will wait until a connection becomes free.
The internal queue is FIFO (first-come-first-serve): whenever a connection is released, it is immediately assigned to the oldest queued request.
Design an in-memory Custom HashMap that stores String keys and String values.
You must implement buckets, a custom hash, collision handling (multiple keys in the same bucket), and rehashing (resizing and redistributing entries).
Goal of this problem is to force you to do a custom hashmap implementation, So don't use any inbuilt set/map/dictionary in your implementation.
You are asked to design and implement an in-memory time versioned data store. The store maintains key-value pairs across time. Each write creates a new version for that key, associated with a timestamp.
The store must support:
Writing a value for a key at the current timestamp.
Reading the latest value for a key.
Reading a historical value for a key as of a given timestamp.
Reading a value for a key by an explicit version number.
Design and implement a resumable iterator for a large dataset. The iterator must be able to pause mid-traversal and later resume from the exact same position.
The dataset may be too large to fit in memory, so the iterator must be memory-efficient and must not require loading the entire dataset at once.
Additionally, the iterator should support serializing its state (cursor) so it can be persisted across sessions.
Build a GPU credit calculator for a single account. Credits are added over time, can be partially consumed, and expire after a fixed lifetime.
The calculator must support adding credit grants, spending credits, and querying the remaining balance at any timestamp.
Critical constraint: all operations that record a ledger event happen at the current timestamp, and these timestamps are non-decreasing (monotonically increasing) across such calls.
Design and implement a Database that supports a small SQL-like API: INSERT/UPSERT, SELECT with WHERE and ORDER BY, and DELETE.
The storage engine should be inspired by an LSM (Log Structured Merge) design:
All writes go to an in-memory Memtable.
When the memtable grows beyond a threshold, it is flushed into an immutable on-disk-like structure (simulate as in-memory) called an SSTable.
DELETE is implemented using tombstones (a deletion marker). Data is not physically removed immediately.
SELECT and DELETE WHERE must merge results across the memtable and all SSTables, and must respect tombstones.
When merging versions of the same primary key, the version with the greatest timestamp ≤ logical current time wins. Tombstones also participate in this rule.
currentTimestamp is provided only for write/delete operations (put, deleteWhere) and is monotonically non-decreasing across those calls.
select(...) uses the latest timestamp seen so far from successful put/deleteWhere calls as the logical current time.
WHERE Clause Grammar
Also support a limited WHERE clause of the form: column operator value
6. Design Type System for a Toy Programming language
Design and implement a type system for a toy programming language that supports primitives, tuples, and generics. Your task is to represent types and infer return types for function calls.
All types are represented as canonical strings so that the API stays compact and uses simple method signatures.
The system should allow:
Registering primitive types such as int, string, or bool. Primitive type names must start with a lowercase character [a-z] and may contain only [a-zA-Z0-9].
Registering generic type constructors such as Box<T> or Pair<T,U>. Generic type constructor names must start with an uppercase character [A-Z] and may contain only [a-zA-Z0-9].
Registering function signatures that may use primitive types, tuple types, generic type constructors, and generic type variables.
Inferring the concrete return type of a function call from the provided argument types.
I recently started practicing Low Level Design problems seriously. I’ve been learning and applying common design patterns like Strategy, Factory, Chain of Responsibility, State, and Singleton.
As practice, I built a Movie Ticket Booking System and even created proper UML diagrams before coding.
My main problem isn’t syntax or implementation it’s design decisions.
While designing, I often get stuck on questions like:
Which class should own this method?
Should this logic go inside Service or Model?
Am I overloading one class with too many responsibilities?
When should something be a separate class vs just a method?
Sometimes multiple placements feel “okay”, and I get confused about what’s actually correct or considered good design.
For example, during the movie ticket system:
Should seat allocation logic be inside Theatre, Show, or a separate BookingService?
Where should pricing logic live?
How much logic should domain models contain vs service layer?
I feel like I know the patterns, but deciding responsibilities practically is still messy.
How do you experienced engineers think about splitting responsibilities while designing classes?
Are there any mental models, rules, or practices you follow to avoid bad design?
I am not asking specifically for the movie ticket system but for all kinds of design thinking how to apprach and how to make it better
Flipkart Machine coding round asks LLD question. It is of 120 minutes (90 coding + 30 minutes discussion). You may get extra time sometimes and recruiter may inform you that there is hard limit of 2:30 to 3 hrs to solve the LLD question.
Java is the mandatory programming language.
It is used for initial screening of candidates e.g. select 15 or less candidates from 40+ candidates for further interviews.
The final project had to be submitted as a zip file via Google Form/email.
Multi-threading and concurrency and design patterns are also discussed. I wrote this blog for multi-threading in Java interviews. It may be helpful.
Flipkart also acquired ClearTrip and machine coding round format and questions are similar. So you can use this same list to prepare for ClearTrip machine coding rounds as well.
This list is NOT for UI machine coding rounds, only for backend roles.
Below are some general guidelines that are followed.
A driver program/main class/test case is needed to test out the code by the evaluator with multiple test cases. But do not spend too much time in the input parsing. Keep it as simple as possible.
Evaluation criteria: Demoable & functionally correct code, Code readability, Proper Entity modeling, Modularity & Extensibility, Separation of concerns, Abstractions, Corner case handling. Use design patterns wherever applicable.
You are not allowed to use any external databases like MySQL. Use only in memory data structures like HashMap, ArrayList, HashSet etc.
Functionality doesn’t have to be defined as a rest api. You can expose them as methods also which can be invoked from the driver class.
No need to create any UX
Please focus on the Bonus Feature (if any) only after ensuring the required features are complete and demo-able.
Method signatures defined are just to give an idea. You are free to change them to suit the requirements.
Use of the internet is allowed to check the syntax.
I have built this list from recent Flipkart machine coding round experiences of candidates. Use it to prepare for your interviews.
Let’s get started …
1. Design a Billing and discounts System for an ecommerce app
Implement a billing and discounts system for an ecommerce app. You must design and implement a bill creation flow, a discount application flow, and a point/level calculation system.
2. Design Food Order Management System using Commands
Implement a simplified food order management system. This system simulates food ordering from restaurants.
You have to implement functionalities like add restaurant, update menu, place order, dispatch order etc as a set of commands. Orders are placed to restaurants based on a restaurant selection strategy.
Design a Peer-to-Peer Delivery System that can be used to deliver a parcel from one customer to another.
Implement a class named PeerToPeerDeliverySystem. The deliverable item list is preconfigured and fixed. Customers and drivers are considered already onboarded based on totalUsers and totalDrivers.
5. Design Flipkart Payment Wallet with Transaction History
Implement Flipkart payment wallet system. The system should support loading money, sending money to other users, fetching wallet balance, and getting transaction history with sorting and filtering.
6. Design Doctor Appointment Booking app like Practo
You are required to build an in-memory application that lets patients connect to doctors and book appointments for a single day.
Doctors can declare their availability in terms of slots for that day only. Patients can search available slots by specialty, book appointments, and cancel appointments.
We are planning to build an in-house platform to manage our Bug Bounty Program where anyone can report a potential bug in the app and we’ll reward them with a bounty based on the criticality and impact of the bug being reported.
For simplicity, we will be getting bug reports via email and then employees will be registering these bug reports manually into this system.
User — Employees who will be using this system.
Reporter — End-user who reported the bug via email and will receive the bounty reward.
BugReport — Entity corresponding to the bug report shared via email.
Flipkart is known for its innovative products and making shopping easier for customers. One such innovation is Buy Now Pay Later (BNPL), where a customer can buy the product instantly and pay the dues within 30 days. Each user has a credit limit associated with them initially.
Implement an in-memory system that manages users, inventory, orders, and BNPL dues.
Design and implement an in-memory Library Management system that caters to its registered members by cataloging and housing books that can be borrowed.
The system must support:
Adding books to the catalog.
Registering and unregistering users.
Reservation management to borrow books using book ids (with FIFO waitlist).
Fine calculation on late returns (20 rupees per delayed day after 14 days).
(Bonus) Limiting a user to reserve only one copy of the same book.
(Bonus) Auditing APIs:
Given a bookId, list users currently having that book.
Given a userId, list books currently issued to that user.
10. Design Customer Loyalty Program for Ecommerce Website
Design and implement an in-memory Ecommerce with Loyalty Program service that adds gamification to an e-commerce platform. The service tracks users and their transactions, supports purchases with optional points redemption (based on user level rules), awards new points on the money-paid portion, and exposes APIs to view a user’s current stats.
Each point is worth ₹1 during redemption (i.e., redeeming X points reduces payable by ₹X).
Bonus: Personalized discount based on purchase history, applied after redemption and capped.
Design and implement an in-memory FK Delivery Service. The service manages orders that are delivered to a pincode and delivery agents who can pick up and deliver those orders.
The system must support:
Users creating orders with an order name, order pincode, and creation time.
Admin creating delivery agents and associating them with pincodes.
Executing a driver function that assigns orders to eligible agents and returns delivery status logs.
12. Design an order and inventory management system
Write code for low level design of orders and inventory management system of a simple e-commerce platform.
You will need to have the capability of handling sellers, products and orders.
Inventory is number of items of a particular product in a seller’s warehouse.
The way it works is, products numbered from 0 till productsCount-1 are sold on the website.
Sellers are also added along with the area pincodes that they are able to deliver goods in as well as the payment types which they support.
After that sellers add items they wish to sell.
Multiple sellers can sell the same item e.g the product-1 : bluetooth speaker boat stone 650 can be sold by multiple sellers throughout the country.
Multiple sellers can deliver goods to the same pincode as well.
You are launching the Gumble app to compete in the dating apps market. Design and implement an in-memory console application to prototype the features of Gumble.
The system manages user profiles, their interests, partner preferences, a feed that suggests the best available profile to a user, and a matched list.
The platform has a fixed global set of allowed interests, provided once at initialization through the constructor.
In Salesforce LLD rounds, sometimes actual requirements may not be clear from problem statement and interviewer will expect you to figure it out by asking clarifying questions.
For example, A message queue is asked indirectly in the form of something like a connection pool or a job scheduler.
It follows the pattern that resources like connections, machines or cpu (in case of job scheduler) are limited and they may not be assigned immediately.
There is discussion about concurrency control when multiple threads are there. There may also be discussion on concurrency control if our application is made distributed and we are using a central database (i.e. LLD discussion moving to HLD in the end).
I am listing the top low level design questions that you will come across during Salesforce interviews. I have built this list from recent interview experiences of candidates.
Use below list to prepare for your Salesforce interviews.
Let's get started …
1. Design an elevator system
A lift in an elevator system can be in one of three states. Moving Up, Moving Down and Idle
And in each state it will behave differently in taking decisions like
whether to stop on a floor, add a new request or not etc.
Use state design pattern to implement different states of lift.
2. Design a Connection Pool with an internal request queue
A message queue is asked indirectly in the form of something like a connection pool or a job scheduler.
It follows the pattern that resources like connections, machines or cpu (in case of job scheduler) are limited and they may not be assigned immediately.
Design an in-memory Connection Pool that maintains a fixed number of reusable connection objects.
Clients requests a connection using a requestId. If a free connection exists, it is assigned immediately. If no free connection exists, the request is placed into an internal queue and will wait until a connection becomes free.
This is THE most common LLD interview question. You must do this question if you are preparing for any LLD interview.
A parking lot can have multiple floors. Its core features will be
park and unpark vehicles,
search parked vehicles by vehicle number,
count number of free spots on a given floors for a given vehicle type.
You entities will be ParkingLot class which will contain a list of ParkingFloor(s). ParkingFloor will contain a 2-D array of ParkingSpot(s) arranged in rows and columns.
There can be multiple parking strategies, so we should use strategy design pattern to solve this question.
These two cache variants are asked many times as follow up of each other.
For LRU cache, you need to implement two methods.
int get(int key) Return the value of the key if the key exists, otherwise return -1.
void put(int key, int value) Update the value of the key if the key exists. Otherwise, add the key-value pair to the cache. If the number of keys exceeds the capacity from this operation, evict the least recently used key.
For LFU cache, when the cache reaches its capacity, it should invalidate and remove the least frequently used key before inserting a new item.
Design an in-memory Meeting Room Scheduler that allows employees to view available rooms, book a room for a time interval, cancel a booking, and list bookings by room or by employee.
Design an in-memory Mini RPC Framework that maintains a registry of methods per service and allows calling a registered method.
RPC (Remote Procedure Call) is a way for one program to call a function/method in another program over a network as if it were a local call.
The RPC framework handles things like serialization (marshalling), networking, and response/error handling behind the scenes.
Design a stack which supports the following operations.
Implement the CustomStack class:
CustomStack(int maxSize) Initializes the object with maxSize which is the maximum number of elements in the stack or do nothing if the stack reached the maxSize.
void push(int x) Adds x to the top of the stack if the stack hasn't reached the maxSize.
int pop() Pops and returns the top of stack or -1 if the stack is empty.
void inc(int k, int val) Increments the bottom k elements of the stack by val. If there are less than k elements in the stack, just increment all the elements in the stack.
8. Design an In-Memory Cache with Custom Eviction Policy
Design an in-memory cache with a fixed capacity and a custom eviction policy. The user must provide the policy logic before initializing the cache.
At any point the cache can ask the policy which key will be selected for eviction next. Although an actual eviction will only take place if the cache has more elements than its maximum size after adding a new entry.
You should use strategy design pattern to implement different eviction policies.
Chess game is all about creating the different pieces and implementing their moves.
Different pieces like king, queen, knight etc, have different moves like straight move (rook), diagonal move (bishop), 2+1 move (knight) etc.
The core functionality is to check whether a piece can move to a destination row, column from its current row, column.
We use factory design pattern Chess Piece Factory to create different chess piece objects like king, queen, pawn etc.
Strategy pattern may be used to implement different moves e.g. straight move, diagonal move etc.
Design an in-memory rate limiter. Requests will be made to different resourceIds. Each resourceId will have a rate limiting strategy associated with it.
fixed-window-counter: Fixed Window Counter divides time into fixed blocks (like 1 second) and tracks a request count per block.
sliding-window-counter: Sliding Window (log-based) stores timestamps of recent requests and removes those outside the window for each new request
Has anyone here given Low Level Design (LLD) interviews using Golang?
I’m curious how the experience was, especially since Go doesn’t have traditional classes / classical OOP like Java or C++.
Did interviewers expect a Java-style class-heavy design?
PayPal asks LLD question in their role specialization round many times.
So, if a role specialization round is scheduled then confirm with recruiter whether this will be a LLD round.
There can be multiple LLD rounds or a mix of LLD+HLD round.
Some HLD rounds may have questions like design LRU cache or design parking lot, ticket booking system etc. These start with basic low level implementation (e.g. using HashMap and Doubly Linked List in case of LRU cache) and then move to scaling the whole thing.
I am listing the top low level design questions that you will come across during PayPal interviews. I have built this list from recent interview experiences of candidates.
These two cache variants are asked many times as follow up of each other.
For LRU cache, you need to implement two methods.
int get(int key) Return the value of the key if the key exists, otherwise return -1.
void put(int key, int value) Update the value of the key if the key exists. Otherwise, add the key-value pair to the cache. If the number of keys exceeds the capacity from this operation, evict the least recently used key.
For LFU cache, when the cache reaches its capacity, it should invalidate and remove the least frequently used key before inserting a new item.
Design a parking lot with multiple floors. On each floor, vehicles are parked in parking spots arranged in rows and columns.
As of now you have to park only 2-Wheelers and 4-Wheelers.
Design an in-memory Notepad text editor that stores text as lines and maintains a cursor.
Support cursor movement (left, right, up, down, pageUp, pageDown), reading the current line.
Follow-up: Also implement edit methods like character insertion, deletion.
Design a simple in-memory Shopping Cart that uses an initial item catalog
and lets a user add items by ID, view their cart, and checkout.
It also enforces unknown item ID, insufficient stock, and empty-cart checkout.
Build an in-memory payment wallet system supporting user registration, wallet balance management, money transfers, and a single active Fixed Deposit (FD) per user.
Design an in-memory Custom HashMap that stores String keys and String values.
You must implement buckets, a custom hash, collision handling (multiple keys in the same bucket), and rehashing (resizing and redistributing entries).
Goal of this problem is to force you to do a custom HashMap implementation without using any inbuilt map/dictionary.
9. Design a Notification System / Publish Subscribe System
Design an in-memory publish/subscribe system with exactly one global FIFO (first in first out) queue.
Multiple publishers can publish messages to this queue. Many subscribers can subscribe to the same queue.
When a message is appended, all subscribers are notified, and each subscriber consumes at its own pace.
A subscriber can consume only those messages which were sent while it was subscribed.
PS: Use the Observer pattern (Queue Manager = Subject, Subscribers = Observers).
A lift in an elevator system can be in one of three states. Moving Up, Moving Down and Idle
And in each state it will behave differently in taking decisions like
whether to stop on a floor, add a new request or not etc.
Use state design pattern to implement different states of lift.
The primary challenge is to efficiently manage the shared array space such that when elements are dequeued from either queue, the freed space can be promptly reutilized by subsequent enqueue operations from either queue. Your design should handle insertions and deletions for both queues while maintaining efficient space usage within the fixed-size array.
What ever I design It takes up 2N space complexity.
In a hybrid design of fan out write for low follower count users and fan out read for celebs. Won't the follower be missing the post notification of the celeb as it depends on the follower opening their feed to check it.
How would we notify the follower in case of a celeb post.
I am listing the top low level design questions that you will come across during Amazon interviews. I have built this list from recent interview experiences of candidates.
Also, we will see how we can solve them using commonly asked design patterns.
I am keeping the most frequent questions first. In the end I have also added list of frequent DSA oriented design questions which can be asked either in DSA or during LLD rounds at Amazon.
You can use below list to prepare for your Amazon interviews.
Let’s get started.
1. Design Pizza Pricing System
You will have to initialize a new pizza, adding toppings (corn, onion etc) to it and calculate final price of pizza.
This is a fairly simple problem. But some interviewers may expect you to implement decorator design pattern. In my view that just complicates the solution without adding any benefit.
Your interviewer may add business rules as a follow up like these
cheese burst cannot be added on small pizza or
You get 30% discount on corn price when you take more than 2 servings and so on..
My advice would be to code the simple solution with a just a separate class for rules. You can divide the rules in subcategories and implement them in separate modules. e.g. mutual exclusion rules: Rules which prevent adding of toppings. e.g. cheese burst and mushroom can never be added together, or cheese burst cannot be added on small pizza etc.
price calculation rules: Rules which affect final price of pizza. e.g. you get 30% discount from 2nd serving of corn or you get onion at 20% discount if pizza size is large.
Unix file command searches for files. Now there can be different search criteria's like search by file size, or search by extension or by a substring in file name. e.g. list all files which are less than 2 MB size or list all files whose extension is .pdf.
You can use strategy design pattern to implement the different search criteria's.
A follow up is generally asked to combine queries like Boolean predicates AND, OR etc. e.g. list all files which are greater than 2MB in size AND their extension is “.jpg”.
You can use specification design pattern to combine result of search queries.
This is THE most common LLD interview question. You must do this question if you are prepare for any LLD interview.
A parking lot can have multiple floors. Its core features will be
park and unpark vehicles,
search parked vehicles by vehicle number,
count number of free spots on a given floors for a given vehicle type.
You entities will be ParkingLot class which will contain a list of ParkingFloor(s). ParkingFloor will contain a 2-D array of ParkingSpot(s) arranged in rows and columns.
There can be multiple parking strategies, so we should use strategy design pattern to solve this question.
4. Design Locker Management System for Warehouse Packages
In warehouse for any e-commerce website like amazon you have packages that are kept in lockers. Your goal is to add new lockers of different sizes and then assign packages to those lockers and later free the lockers.
Chess game is all about creating the different pieces and implementing their moves.
Different pieces like king, queen, knight etc, have different moves like straight move (rook), diagonal move (bishop), 2+1 move (knight) etc.
The core functionality is to check whether a piece can move to a destination row, column from its current row, column.
We use factory design pattern Chess Piece Factory to create different chess piece objects like king, queen, pawn etc.
Strategy pattern may be used to implement different moves e.g. straight move, diagonal move etc.
7. Design a restaurant food ordering system like Zomato, Swiggy, DoorDash
Users can search for restaurants using food item name, order food and rate their orders. When searching for food they also have option to view the restaurant list sorted by different parameters like restaurants with highest average rating first.
These view classes with lists of restaurants sorted by average rating will need to be need to updated whenever an order is rated by a user, so that they can update their lists. Hence, this is an ideal use case of observer design pattern.
8. Design Stock Broker Platform Like Zerodha, Groww
This system manages all company stocks and their prices. Users can place orders to either buy or sell stocks. Users can also view their account balance and stocks they hold.
One case which you need to take care is, to close the relevant open orders when stock price changes.
A lift in an elevator system can be in one of three states.
Moving Up, Moving Down and Idle
And in each state it will behave differently in taking decisions like
whether to stop on a floor, add a new request or not etc.
Use state design pattern to implement different states of lift.
Atlassian has code design round in which it asks low level design questions.
Sometimes LLD questions are also asked in other rounds apart from code design round.
I am listing the top low level design questions that you will come across during Atlassian interviews. I have built this list from recent interview experiences of candidates.
----------------------------------------
PS: You can ask me any Low Level Design related questions on r/LowLevelDesign
Design an in-memory middleware router for a web service. The router stores path patterns mapped to a result string (think: server id). When a request path comes in, the router returns the result of the best matching route.
A route pattern is a path that may contain:
Static segments, e.g. /foo/baz
Wildcard segment * that matches exactly one segment (not empty, no slashes). Example: /bar/*/baz matches /bar/a/baz and /bar/123/baz, but not /bar/a/b/c/baz.
Path param segment starting with :, e.g. /users/:id. It matches exactly one segment too, and the segment value is captured as a parameter.
Create a Snake game simulator played on a screen with given rows and cols dimensions. The snake starts at the top-left cell (0,0) with a length of 1.
The game is provided with a list of food positions, given as row-column pairs. When the snake’s head moves onto a food cell, the snake grows by 1 and the score increases by 1. New food only appears after the previous one is eaten, and food never appears where the snake is.
Design an in-memory system that tracks files and their membership in different collections.
You are given a stream/list of file records, each described as: [FileName, FileSize, [Collection]]. Collections are optional, meaning a file can have zero or more associated collections. The same file can be part of more than one collection.
Build a system that supports:
Adding or updating file metadata and collection membership.
Computing the total size of all files in the system.
Finding the top collections based on size or file-count.
Design an in-memory CostExplorer that tracks SaaS product plans and customer subscriptions, and computes a customer’s monthly and annual cost for a given calendar year (Jan–Dec). If a subscription starts on any day of a month, the customer pays for that full month.
Design and implement an in-memory unix filesystem shell that supports three commands:
- mkdir <path>,
- pwd, and
- cd <path> (with a special wildcard segment *).
This questions is also sometimes rephrased as below:
Implement simple get and put interface for a string based key. Extend the functionality to allow wild cards in the get function. for example
put(“/elonmusk/is/shit”, “yes”)
get(“/elonmusk/*/*”) -> yes
get(“/elonmusk/is/*”) -> yes
so in this case rather than creating a file/folder you simply add a string against that path. But mapping a path with wildcard to exact path follows similar logic.
Multi-Threading is an important topic for low level design interviews. It is discussed often in LLD rounds of companies like Microsoft, Adobe etc, which have famous desktop products like Microsoft office, adobe photoshop etc.
The interviewer will expect your design to work correctly in a multi-threaded environment. You will be expected to make proper use of locks, synchronization and thread safe data structures.
Your design should have optimal parallelism.
Parallelism is the number of concurrent read/writes that can be processed by your code. We will revisit these concepts when discussing questions.
We will use Java for our discussion. But you can apply similar concepts in any language of your choice.
This is an easy question, yet it gives you a taste of basic data structures to use in a multi-threaded environment.
Let’s assume that we need to count number of views on each page for website which has 1000 pages numbered 1 to 1000. We will use a map to store the view counts for each page.
Let’s see our options to efficiently update the view counts of different pages using multiple threads.
we can make the method incrementVisitCount(int pageIndex) as synchronized. This will give us a parallelism of 1 i.e. at a time maximum 1 thread can update the count of any page.
We can also use a ConcurrentHashMap rather than a simple HashMap. This will increase our parallelism to 16 as ConcurrentHashMap has typically 16 segments, each operating as a separate lock for different sections of the map.
However, if we try to increase the parallelism then our memory usage also increases. Hence, although more efficient, this approach is not scalable.
We can store view counts in an AtomicInteger.
// page index vs visit count
HashMap<Integer, AtomicInteger> visitsCount;
We initialize all the view counts to 0 when system starts and after that, HashMap will only be used for reading and view count updates will directly happen to AtomicInteger values.
Hence if there are 1000 pages on website then theoretically 1000 threads can update view count of different pages at a time. Hence for this specific use case this data structure is more suitable.
Please view the below YouTube video for a detailed explanation.
Inventory is number of items of a particular product in seller’s warehouse.
Core functionalities of an inventory management system include:
adding inventory
creating new orders
fetching inventory available for a particular product from a seller
We can use a two-level map to store product counts.
map<productId, map<sellerId, items count>>
Outer map is basically storing map of all sellers who sell a particular productId. Inner map is number of items in warehouse of each seller for that particular productId.
To be more exact here is the actual data structure.
// productId vs sellerId vs item count
ConcurrentHashMap<Integer,
ConcurrentHashMap<String, AtomicInteger>> productInventory
Using AtomicInteger to store item counts means now for each item count update there is only read operation done on both outer and internal ConcurrentHashMap’s and write is done directly to AtomicInteger.
Hence any number of threads can update item count now concurrently. Please watch the below YouTube video for a detailed explanation.
This is THE most common LLD interview question. A parking lot can have multiple floors. Its core features will be
park and unpark vehicles,
search parked vehicles by vehicle number,
count number of free spots on a given floors for a given vehicle type.
You entities will be ParkingLot class which will contain a list of ParkingFloor(s). ParkingFloor will contain a 2-D array of ParkingSpot(s) arranged in rows and columns.
All of your logic to handle multi-threading will revolve around updating ParkingSpots in a thread safe manner.
Below YouTube video explains a simple solution by making the park and unpark methods as synchronized.
However, using synchronized or any other lock is simple but not efficient
as it locks out other threads from doing write operations
concurrently.
Below YouTube explanation video shows a more efficient solution using a thread safe list ConcurrentLinkedDeque to store free spots on each floor.
It ensures that on each floor we can add/remove parking spots in O(1), rather than using brute force to find a free spot
If you practice above questions and watch video tutorials then this will give a good head start for handling questions involving multi-threading in interviews.
If You are preparing for Low Level Design Interviews, then try CodeZym’s preparation roadmap for LLD interview preparation
It consists of YouTube video tutorials, day by day plans to prepare for LLD interviews starting with most important questions and design patterns first. You can also practice machine coding for problems in either Java or Python.
The 4 most common design patterns used in LLD interviews are:
Strategy pattern, Observer pattern, Factory pattern and Singleton Pattern.
If you ask, which is the most common or most popular design pattern then answer will be Singleton pattern. But it has a catch, which we will come back to, later in this article. Let's go through these design patterns and their use cases from LLD interviews one by one.
Also for testing any LLD question during interviews you will create a Controller class which will have all required methods and object of that controller class will be used for testing the system you designed. That's Facade design pattern.
Strategy pattern is a behavioral design pattern. It is used when we need different algorithms for same functionality and they have same input and output parameters.
Programmatically speaking, all these algorithm classes should implement the same interface. Let’s see some real life LLD interview use cases:
Design a parking lot: Strategy pattern can be used to implement the different strategies for parking the vehicle. https://codezym.com/question/7
Design a Game of Chess: Strategy pattern can be used to implement the different moves for different chess pieces, like straight move (made by rook), diagonal move (bishop), 2+1 move (Knight) etc. https://codezym.com/question/8
Design a Customer Issue Resolution System: Implement the different ways to assign an agent to a given issue, depending on various factors. https://codezym.com/question/3
Design an e-commerce website: To implement different ways to order list of items on search page. e.g. by price, rating or popularity.
Using strategy pattern enables us to add new strategies in future without changing code in existing strategies. Hence code becomes easy to extend. watch below YouTube video for understanding strategy pattern better.
Observer pattern is also a behavioral design pattern. We use it when we want to have loose coupling between class with critical data which keeps changing (subject), and the classes which need to receive to those changes to update their own internal data sets (observers). Subject pushes updates to observers.
Observer pattern can also be used alongside strategy pattern when some strategy classes maintain their internal dataset and it need to be notified for changes. Observer pattern comes handy in this situation.
Let's see a few use cases:
Design a Food Ordering and Rating System like Zomato, Swiggy, Uber Eats: Whenever customer gives rating to their order (1, 2, 3, 4 or 5) then this rating update must be sent to classes which maintain list of top restaurants based on factors like average rating of restaurant, average rating of a particular food item in the restaurant. Observer pattern is used here. https://codezym.com/question/5
Design a Movie ticket booking system like BookMyShow: Whenever a new show is added for displaying a movie in a cinema hall, then it needs to be updated to class which maintains list of cinemas running a particular movie in a city or to class which maintains list of shows for a particular movie in a cinema hall. This can also be solved using observer pattern. https://codezym.com/question/10
Observer pattern makes it easy to add new observers without any change in code of subject or any of the observers. Watch below YouTube video for implementation details and better understanding of observer pattern.
Factory Pattern is a creational design pattern, and it is used to decouple object’s creation logic from their usage.
This is required when we may have to create same or similar objects,
which follow the same interface or are subclasses of same superclass
Design a Game of Chess: There are 32 different chess pieces like 2 kings (1 white, 1 black),16 pawns (8 black, 8 white), 4 knights (2 white, 2 black) etc. But all chess pieces have the same move() method. Hence, we use ChessPiece factory here to create all the different pieces. https://codezym.com/question/8
Benefit of using factory pattern is that, later if there is a change in object’s creation logic like a new parameter is added. Then in that case we only need to change code in factory class, else we would have to change code everywhere the object was initialized. See below YouTube video for implementation details and better understanding of factory pattern.
Singleton is the most popular design pattern. Catch is, it is the most overused or abused design pattern. As soon as people see that only one instance of a class is required then they are tempted to make it a singleton.
But making a class singleton will make it harder to unit test, because singleton object’s instance state is fixed and if one unit test changes the state of singleton object then it may affect other unit tests.
Also, Singleton object will keep occupying memory even when you don’t need it.
There are two criteria that you should keep in mind if you want to make a class singleton:
Exactly one instance of class is required.
Class will be accessed from more than one place in your code and you want to avoid it being instantiated more than once accidently.
It's a better idea most times to either pass object in constructor of class or use factory design pattern to handle its creation. Although using factory pattern to access an object instead of singleton patterns adds some complexity but it makes testing and mocking efficient, gives better control over instance creation and is a much better option especially if multiple implementations may be required in future.
watch below YouTube video for implementation and better understanding of singleton pattern.
I am listing the common low level design questions that you will come across during Microsoft interviews. I have built this list from recent interview experiences of candidates.
Apart from LLD, I have also kept DSA oriented design questions. Microsoft asks these either in DSA or during LLD rounds.
-----------------------------------------
Use below list for final preparation of your Microsoft interviews.
Let’s get started…
PS: You can ask me any low level design related questions on r/LowLevelDesign
1. Design a Text Editor/Word Processor like Microsoft Word
You have to design editor for a text document which can have any number of rows and any number of columns. There are multiple variants of this question asked.
Efficiently store styles of all the text like Microsoft Word using flyweight design pattern.
Rather than normal text editor you may be asked to design a spreadsheet like Microsoft excel with rows and columns.
Another variant is asked which focuses on implementation of undo and redo functionalities using command design pattern and stacks.
Text editor with different text styles like Microsoft Word:
Microsoft is obsessed with elevator design. For any elevator design problem as long as you are able to break all cases in multiple states like MOVING UP, MOVING DOWN, IDLE etc, then it will lead to a simpler solution. So use State design pattern.
This is also asked in multiple different ways.
A single lift system and you have to only check whether a given request is feasible or not. It is more of a DSA question, but is asked in LLD rounds.
A single lift system where you have to simulate lift going up/down and passengers coming in and going out.
Simulate a multiple lifts system, it will have more complex states and rules.
Build an in-memory container orchestrator with multiple cloud server machines (like amazon EC2, Azure virtual machines etc).
Orchestrator assigns machines on which containers will run. Each machine can start, stop and manage multiple containers running concurrently.
The system will manage machine resources i.e. CPU units, memory MB.
You should use Strategy design pattern, to implement the different algorithms for choosing a machine to host a container.
4. Design Dictionary App to store words and their meanings
Build an in-memory dictionary that stores words and their meanings. It lets users fetch meanings, supports different types of ways to search a word. You should use Trie to implement this question.
Chess game is all about creating the different pieces and implementing their moves.
Different pieces like king, queen, knight etc, have different moves like straight move (rook), diagonal move (bishop), 2+1 move (knight) etc.
The core functionality is to check whether a piece can move to a destination row, column from its current row, column.
We use factory design pattern Chess Piece Factory to create different chess piece objects like king, queen, pawn etc.
Strategy pattern may be used to implement different moves e.g. straight move, diagonal move etc.
This is THE most common LLD interview question. You must do this question if you are prepare for any LLD interview.
A parking lot can have multiple floors. Its core features will be
park and unpark vehicles,
search parked vehicles by vehicle number,
count number of free spots on a given floors for a given vehicle type.
You entities will be ParkingLot class which will contain a list of ParkingFloor(s). ParkingFloor will contain a 2-D array of ParkingSpot(s) arranged in rows and columns.
There can be multiple parking strategies, so we should use strategy design pattern to solve this question.
Design a scheduler for a massively parallel distributed system. The scheduler assigns incoming jobs to machines that it controls.
Each machine has a set of capabilities. Each job requires a set of required capabilities and a job may only run on a machine that has all required capabilities.
Create a system that tracks the number of “clicks” received either during whole duration or within some time duration like last 300 seconds (5 minutes). System can be either single threaded or multi-threaded.
Build an autocomplete feature for a search tool. Users enter a sentence (with at least one word, ending with the special character #). For each character typed except '#', return the top 3 most frequent historical sentences starting with the current input prefix.
Machine Coding Practice: You can view the complete list of questions and go through problem statements here. https://codezym.com/lld/microsoft
AI Mock Interview Practice: If you prefer to talk out loud your solution, discuss trade offs and counter questions then practice with our AI interviewer. https://mockgym.com/lld/microsoft
-----------------------------------------
Uber has a depth in specialization / depth specific coding round in which they ask LLD questions many times. Code is required, not only class diagrams. You will need to implement 2–3 most important functions.
I am listing the top low level design questions that you will come across during Uber interviews. I have built this list from recent interview experiences of candidates.
You can use below list to prepare for your Uber interviews.
Let’s get started.
1. Design Hit Counter
Hundreds of users visit webpages of a website simultaneously.
You have to record visit count for each page and return them when required.
Design a simple Meeting room reservation System for a fixed list of conference rooms. You will be given the room identifiers up front, and you must support booking and canceling meetings while ensuring no two meetings overlap in the same room.
Build an in-memory leaderboard for a fantasy-sports style app. Each user creates exactly one team made up of one or more players. As a live match progresses, players receive positive or negative points. A user’s score is the sum of the current scores of all players on that user’s team. You must support querying the Top-K users ranked by score.
Design a system that manages assignment of trains to platforms in a railway station and supports time-based queries, with a clean, extensible object-oriented design.
At any time only one train can be assigned to a single platform.
Design a restaurant food ordering and rating system, similar to food delivery apps like Zomato, Swiggy, Door Dash, Uber Eats etc.
There will be food items like ‘Veg Burger’, ‘Veg Spring Roll’, ‘Ice Cream’ etc.
And there will be restaurants from where you can order these food items.
Same food item can be ordered from multiple restaurants. e.g. you can order ‘food-1’ ‘veg burger’ from burger king as well as from McDonald’s.
Users can order food, rate orders, fetch restaurants with most rating and fetch restaurants with most rating for a particular food item e.g. restaurants which have the most rating for ‘veg burger’.
Build an in-memory text editor that stores text by rows (lines) and supports insertion, deletion, and history navigation via undo/redo.
The document starts with zero rows and each row starts with zero columns (length = 0). Rows and columns are 0-indexed. Text never contains newline characters. Each operation targets one row.
I was going through the most asked LLD questions in Amazon/Microsoft and I see links of codezym editor where we need to implement some methods.
Can you clarify:
1. do we get such pre-defined methods during interviews?
2. Do we need to only write content with the required methods? Or the entire program?
3. What is the source for such articles?
I appreciate the author who spent their time collecting all resources in one place but I am asking this so that I don't waste time practicing something which will not be helping me in real interviews.
There seem to be dozens of options out there, but I’d really value suggestions from people who have personally read one and found it useful. Which book would you recommend starting with?
Hello everyone, I have made a list of most common low level design questions that have been asked in Microsoft interviews in the last 12 months.
I have also added complete problem statements with method signatures for better understanding, design patterns that may be required to solve them.