7 Days Preparation Plan

This roadmap will specifically concentrate on getting
you ready for Low Level Design Interviews

We don't intend to cover the comprehensive
low level design for all the components and
hundreds of classes in large systems like
Parking Lot, Food Ordering app and other systems.

1. We will specifically deep dive into the
   core features of questions which interviewers
   expect to discuss with you in a LLD interview

2. YouTube video solutions will also teach you how to
   explain your solution to the interviewer step by step.



YouTube Video Thumbnail
Link
If you have an interview tomorrow, then only read theory from below.
In an hour you will know about different type of questions and
design patterns used to solve them.

YouTube Video Thumbnail
Link
   
Plan is to start each day with a few short videos
to get you in preparation mode and then do
one coding question covering one or more design patterns.

Languages: As of now Java and Python are supported.



There are two types of low level design interview formats:
1. 75 to 90 minutes of machine Coding
2. 45-60 minutes of face to face discussion

Watch the Youtube Video on the right for details.
YouTube Video Thumbnail
Link
YouTube Video Thumbnail
Link
YouTube Video Thumbnail
Link
YouTube Video Thumbnail
Link

Following are the three things interviewer is looking for

1. How you break your solution in multiple classes
2. Usage of design patterns to solve the problem
3. How you handle multithreading

Try to complete Coding for questions even if
you have to watch the solution multiple times,
because that will make you comfortable with
the different data structures
especially the thread safe data structures and edge cases
which will be useful when interviewer tweaks the question a little.


These are the most common design patterns in LLD interviews.
Strategy, Factory, Singleton and Observer
We will practice them first and them move on to other design patterns.

Practice Problem
Design a Parking Lot
https://codezym.com/question/1

Parking Lot design is sort of the Hello World of low level design questions.
Most people start their LLD interview preparation with this question.

Python solution video on the right takes you through the core features
like park, remove vehicle, search vehicle and also teaches you
how to clearly explain your design to interviewer step by step
in a 45-60 minute LLD interview.

For Java , we have to implement our solution for a multi-threaded
environment using locking and thread safe data structures.
Video on the right show a simple solution using synchronized keyword
which is the popular locking mechanism in Java.

However, using synchronized or any other lock is simple but not efficient
as it locks out other threads from doing write operations
concurrently.


YouTube Video Thumbnail
Link

YouTube Video Thumbnail
Link
YouTube Video Thumbnail
Link
Video on the left shows a more efficient solution using a thread safe list
ConcurrentLinkedDeque to store free spots on each floor.
It ensures that on each floor rather than using brute force
to find a free spot, we can add/remove parking spots in O(1)

Strategy Design Pattern

Strategy Pattern is used when we need different algorithms
for the same functionality. Some examples are :
1. Different moves in chess: straight, diagonal, 2+1 move
2. different ways to order list of items e.g. by price, rating, most ordered etc
YouTube Video Thumbnail
Link
YouTube Video Thumbnail
Link

Practice Problem
Design a Parking Lot using Strategy Pattern
https://codezym.com/question/7
Parking Lot design is one of the most common questions asked
in a Low Level Design Interview.
In this question we have to implement two different parking strategies,
so you should use strategy pattern here.

YouTube Video Thumbnail
Link

Observer Design Pattern

Observer Pattern is a behavioural design pattern and
it is used when you want to have loose coupling
between data which is getting changed and
multiple views or observers which need to receive the changes.

example: Giving 1 to 5 star rating to a product on ecommerce website
needs to be observed by the class which shows list of top rated products.

Observer pattern is generally used along with strategy pattern
to inform different strategy classes about
changes occurring in the common data structure.

example: a customer support system may have different strategy classes
to assign an agent to a customer support call.
Also each strategy need to be informed whenever
an agent is assigned a case so that they can decide
whether to assign new cases to this agent or not.
Observer pattern will be used in this case.

YouTube Video Thumbnail
Link


YouTube Video Thumbnail
Link

Practice Problem
Design a food ordering and rating system like
  Zomato, Swiggy, DoorDash
https://codezym.com/question/5

This system will have functionality to order food, rate orders
and list top restaurants based on their rating

Now whenever an order is rated then it has to observed
by classes which return top restaurants lists based on their rating.
So this is an ideal use case for observer design pattern

Watch Java and Python video solutions on the right for explanation.

YouTube Video Thumbnail
Link
   
YouTube Video Thumbnail
Link

Factory Design 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 similar objects
which follow the same interface or are subclasses of same superclass

Some example are :
- Creating different pieces in chess e.g. pawn, king, queen etc.
- Creating different type of cars in a car race video game.
YouTube Video Thumbnail
Link
YouTube Video Thumbnail
Link

YouTube Video Thumbnail
Link
YouTube Video Thumbnail
Link
Singleton Design Pattern

Singleton Pattern is used when we need a
single instance of an object.
e.g. A connection pool manager for managing
database connection will be a singleton.
Generally factories are implemented as a singleton

Practice Problem
Design Chess Game
https://codezym.com/question/8

In Low Level Design of chess we use following design patterns
1. Chess Piece Factory to create different chess piece objects like king, queen, pawn etc
2. Strategy pattern to implement different moves e.g. straight move, diagonal move etc.
3. Singleton pattern to ensure there is a single instance of chess piece factory object.

YouTube Video Thumbnail
Link

Flyweight Design Pattern

Flyweight design pattern is used when we need to
create a large number of similar objects
It helps us save memory space by sharing
constant state among objects.

  Some examples are
- Sharing 3-d images of thousands of soldiers
  in a computer war game
- Sharing styles of characters in a text editor
  like Microsoft word.
YouTube Video Thumbnail
Link
YouTube Video Thumbnail
Link

Practice Problem
Design a Text Editor/Word Processor like Microsoft Word
https://codezym.com/question/9

In a text editor, each character can have a different style
in terms of parameter like colour, font size etc

Also there can be millions of characters in a text editor file,
but total number of different styles used will be just from
a few 100's to a few 1000's

So it makes sense to share character style as constant intrinsic state
and reduce memory footprint of program
YouTube Video Thumbnail
Link

YouTube Video Thumbnail
Link

State Design Pattern

State is a behavioural design pattern and it is used when
an object has to change its behaviour as its internal state changes.

For example an ATM machine may be in different states
like idle, money withdrawal in progress, validating pin etc
and will respond to keyboard button presses differently in each state.
The same keyboard can be used to input user's PIN as well as
mobile number, depending on the current state of ATM.

another example is of a Cab booking System
Ride can be in states like:
Ride Requested, Ongoing, Finished, Cancelled
which will have multiple states and in each of these states
calculation for a common behaviour like
timeTakenToReachDestaination() will be different.

YouTube Video Thumbnail
Link

YouTube Video Thumbnail
Link

Practice Problem
Design an elevator management System with multiple lifts
https://codezym.com/question/2

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
So we will use state design pattern to solve this problem.

YouTube Video Thumbnail
Link

Multi-Threading

In LLD interviews, after design patterns, discussion moves on to multi-threading.
For these question you have to use synchronization, locks and thread safe data structures.

If you are using Java then you have access to thread safe data structures
like AtomicInteger, ConcurrentHashMap, ConcurrentLinkedDequeue etc.

Practice Problem
4. Design an order and inventory management system https://codezym.com/question/4
An inventory management system of a
simple e-commerce platform,
needs to have the capability of
handling sellers, products and orders.
Inventory is number of items of a
particular product in a seller's warehouse.
   


YouTube Video Thumbnail
Link




YouTube Video Thumbnail
Link
   
3. Design a customer issue resolution system https://codezym.com/question/3
Customer support is nothing but a group of agents
with skills for solving a set of issues.

Customer Issues can be classified into multiple types
like order delayed, Payment Related etc.
A customer issue resolution system is used to
assign customer's issues to agents.




Best of Luck