0% found this document useful (0 votes)
138 views59 pages

Microsoft Engineer SDE2 Handbook

The document outlines a structured approach to restarting Data Structures and Algorithms (DSA) preparation, emphasizing starting with the Blind 75 problems and focusing on high ROI areas like DFS, BFS, and two pointers. It provides coding patterns, essential data structures, and a comprehensive list of problems to practice across various categories such as arrays, dynamic programming, and trees. Additionally, it includes tips on time complexities and resources for mastering coding challenges effectively.

Uploaded by

harish
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
138 views59 pages

Microsoft Engineer SDE2 Handbook

The document outlines a structured approach to restarting Data Structures and Algorithms (DSA) preparation, emphasizing starting with the Blind 75 problems and focusing on high ROI areas like DFS, BFS, and two pointers. It provides coding patterns, essential data structures, and a comprehensive list of problems to practice across various categories such as arrays, dynamic programming, and trees. Additionally, it includes tips on time complexities and resources for mastering coding challenges effectively.

Uploaded by

harish
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 59

Phase 3 : Restarting DSA from scratch

- Don't waste time thinking I will read all concepts and then get started, we never get around
to doing it!
- Start with Blind 75, to get a taste of Problem solving once again, start with Easy Problems
and then tackle Mediums later, else you may get demotivated and bye bye switch.
- We will revise concepts as we tackle them : Priority queue, Arrays, Merge Sort, etc.
- Then we will Focus on mastering the high ROI areas for Interviews.
- After that we will focus on some coding Patterns
- Then a deep dive into some more problems that are frequently asked in coding interviews
- And then we will keep doing the daily streak to remain in touch with coding!!

Highest ROI: DFS, BFS, Two pointers

Depth-first search(DFS), Breadth-first search(BFS) and Two pointers, make up a good


portion of all interview problems. DFS in particular can be used to solve a wide range of
problems from tree to graph to combinatorial problems and is very useful in tech interviews.
We have a detailed explanation on each of these topics.

Linked list, stack, and queue high ROI

These problems get asked a lot, but there aren't many variations. For example, the linked list
category has several classic problems such as reversing a linked list, finding the middle node
of a linked list, and linked list cycle detection that get asked repeatedly.

Priority Queue/heap medium ROI

Priority queue and heap show up surprisingly more often than most would think. The classic
problems include the median of a data stream, k closest points.

Greedy, Dynamic programming

Dynamic programming (DP) is hard to summarise and does not frequently appear (unless you
are interviewing Google, whose engineers like to ask DP problems). There are a few classic
problems you may want to know such as house robber and robot paths. Otherwise, you
should probably focus on higher ROI areas if you are short on time. Also, if you can't figure
out a dynamic programming solution, you can always do DFS + memoization which does the
same thing.

Each greedy problem is different, and it's hard to summarise a pattern, and the correctness of
your solution often requires rigorous mathematical proof that is hard to learn in a short time.
Therefore, we consider the greedy problem to be low ROI.

38 | Pratham Kohli
Pro tip 1: Catch up on STL Libraries of the language you will code in for DSA, seeing this
now will help you get up to speed when you see solutions of other people in the Leetcode
Discuss Section as you solve problems

1. C++ : Link to STL Video


2. Java : Link to STL Videos
3. Python : Need to make a youtube search for this one as well!

Pro tip 2: Be very thorough with Time Complexities of Data Structures and your solutions.
Messing up the Time complexity can cost you your interview, even if you did everything
right, including the Implementation of Code.

Time Complexity Cheat Sheets :


- Big O Cheat Sheet : link
- Time Complexity Cheat Sheet : link
- Artistic Time Complexity Cheat Sheet: link

Blind 75 Sheet questions:

Alright buddy, time to get your hands dirty!! Let’s Code!!

Pro Tip 3: Don’t Spend more than 40 mins on one question, 1.5 hrs at max if it is Hard ( but
try sticking to the 40-45 mins mark).

Pro Tip 4: Even if you were able to solve the question, check the Leetcode Discuss section
for other possible solutions.
It opens up your mind to solutions you didn’t know existed. You get the Eureka moments!!
You exercise your mind and understand how other people think.
Don’t skip this GOLDMINE!!

Array
● Two Sum
● Best Time to Buy and Sell Stock
● Contains Duplicate
● Product of Array Except Self
● Maximum Subarray
● Maximum Product Subarray
● Find Minimum in Rotated Sorted Array
● Search in Rotated Sorted Array
● 3 Sum

Complete Switching Bootcamp | 39


● Container With Most Water

Binary
● Sum of Two Integers
● Number of 1 Bits
● Counting Bits
● Missing Number
● Reverse Bits

Dynamic Programming
● Climbing Stairs
● Coin Change
● Longest Increasing Subsequence
● Longest Common Subsequence
● Word Break Problem
● Combination Sum
● House Robber
● House Robber II
● Decode Ways
● Unique Paths
● Jump Game

Graph
● Clone Graph
● Course Schedule
● Pacific Atlantic Water Flow
● Number of Islands
● Longest Consecutive Sequence
● Alien Dictionary (Leetcode Premium)
● Graph Valid Tree (Leetcode Premium)
● Number of Connected Components in an Undirected Graph (Leetcode Premium)

40 | Pratham Kohli
Interval
● Insert Interval
● Merge Intervals
● Non-overlapping Intervals
● Meeting Rooms (Leetcode Premium)
● Meeting Rooms II (Leetcode Premium)

Linked List
● Reverse a Linked List
● Detect Cycle in a Linked List
● Merge Two Sorted Lists
● Merge K Sorted Lists
● Remove Nth Node From End Of List
● Reorder List

Matrix
● Set Matrix Zeroes
● Spiral Matrix
● Rotate Image
● Word Search

String
● Longest Substring Without Repeating Characters
● Longest Repeating Character Replacement
● Minimum Window Substring
● Valid Anagram
● Group Anagrams
● Valid Parentheses
● Valid Palindrome
● Longest Palindromic Substring
● Palindromic Substrings
● Encode and Decode Strings (Leetcode Premium)

Complete Switching Bootcamp | 41


Tree

● Maximum Depth of Binary Tree


● Same Tree
● Invert/Flip Binary Tree
● Binary Tree Maximum Path Sum
● Binary Tree Level Order Traversal
● Serialize and Deserialize Binary Tree
● Subtree of Another Tree
● Construct Binary Tree from Preorder and Inorder Traversal
● Validate Binary Search Tree
● Kth Smallest Element in a BST
● Lowest Common Ancestor of BST
● Implement Trie (Prefix Tree)
● Add and Search Word
● Word Search II

Heap
● Merge K Sorted Lists
● Top K Frequent Elements
● Find Median from Data Stream

Other Important Links:


● Grind 75
● If you are new to programming, know some languages already : Interviewbit
question list is a great great resource to practise things. In my college placement
prep time I did all of it and the results for me were insane!!
○ Complete this till Level 8 and you will have such a good grip on
everything : link. But this demands a lot of time, only recommended for
college students or somebody looking for their 1st job!!

42 | Pratham Kohli
20 Coding Patterns to know before your Interviews

( Courtesy: DesignGurus )

Coding patterns enhance our “ability to map a new problem to an already known problem.”

Coding Patterns simply mean multiple problems having similar kind of solutions and which
can be solved in a similar way

1. Sliding Window
Usage: This algorithmic technique is used when we need to handle the input data in a specific
window size.

DS Involved: Array, String, HashTable

Sample Problems:
- Longest Substring with 'K' Distinct Characters
- Fruits into Baskets

Complete Switching Bootcamp | 43


2. Islands (Matrix Traversal)

Usage: This pattern describes all the efficient ways of traversing a matrix (or 2D array).

DS Involved: Matrix, Queue

Sample Problems:
- Number of Islands
- Flood Fill
- Cycle in a Matrix

44 | Pratham Kohli
3. Two Pointers

Usage: This technique uses two pointers to iterate input data. Generally, both pointers move
in the opposite direction at a constant interval.

DS Involved: Array, String, LinkedList

Sample Problems:
- Squaring a Sorted Array
- Dutch National Flag Problem
- Minimum Window Sort

4. Fast & Slow Pointers


Usage: Also known as Hare & Tortoise algorithm. This technique uses two pointers that
traverse the input data at different speeds.

DS Involved: Array, String, LinkedList

Sample Problems:
- Middle of the LinkedList
- Happy Number
- Cycle in a Circular Array

Complete Switching Bootcamp | 45


5. Merge Intervals
Usage: This technique is used to deal with overlapping intervals.

DS Involved: Array, Heap

Sample Problems:
- Conflicting Appointments
- Minimum Meeting Rooms

6. Cyclic Sort
Usage: Use this technique to solve array problems where the input data lies within a fixed
range.

DS Involved: Array

Sample Problems:
- Find all Missing Numbers
- Find all Duplicate Numbers - Find the First K Missing Positive Numbers

46 | Pratham Kohli
7. In-place Reversal of a LinkedList

Usage: This technique describes an efficient way to reverse the links between a set of nodes
of a LinkedList. Often, the constraint is that we need to do this in-place, i.e., using the
existing node objects and without using extra memory.

DS Involved: Array

Sample Problems:
- Reverse every K-element Sub-list
- Rotate a LinkedList

8. Breadth-First Search
Usage: This technique is used to solve problems involving traversing trees or graphs in a
breadth-first search manner.

DS Involved: Tree, Graph, Matrix, Queue

Sample Problems:
- Binary Tree Level Order Traversal
- Minimum Depth of a Binary Tree
- Connect Level Order Siblings

9. Tree Depth First Search


Usage: This technique is used to solve problems involving traversing trees or graphs in a
depth-first search manner.

DS Involved: Tree, Graph, Matrix

Sample Problems:
-Path With Given Sequence
-Count Paths for a Sum

10. Two Heaps

Usage: In many problems, we are given a set of elements that can be divided into two parts.
We are interested in knowing the smallest element in one part and the biggest element in the
other part. As the name suggests, this technique uses a Min-Heap to find the smallest element
and a Max-Heap to find the biggest element.

DS Involved: Heap, Array

Complete Switching Bootcamp | 47


Sample Problems:
-Find the Median of a Number Stream
-Next Interval

11. Subsets
Usage: Use this technique when the problem asks to deal with permutations or combinations
of a set of elements.

DS Involved: Queue, Array, String

Sample Problems:
- String Permutations by changing case
- Unique Generalized Abbreviations

12. Modified Binary Search


Usage: Use this technique to search a sorted set of elements efficiently.

DS Involved: Array

Sample Problems:
- Ceiling of a Number
- Bitonic Array Maximum

13. Bitwise XOR

Usage: This technique uses the XOR operator to manipulate bits to solve problems.

DS Involved: Array, Bits

Sample Problems:
- Two Single Numbers
- Flip and Invert an Image

14. Top ‘K’ Elements


Usage: This technique is used to find top/smallest/frequently occurring ‘K’ elements in a set.

DS Involved: Array, Heap, Queue

Sample Problems:
- ‘K’ Closest Points to the Origin
- Maximum Distinct Elements

48 | Pratham Kohli
15. K-way Merge
Usage: This technique helps us solve problems that involve a list of sorted arrays.

DS Involved: Array, Queue, Heap

Sample Problems:
- Kth Smallest Number in M Sorted Lists
- Kth Smallest Number in a Sorted Matrix

16. Topological Sort

Usage: Use this technique to find a linear ordering of elements that have dependencies on
each other.

DS Involved: Array, HashTable, Queue

Sample Problems:
- Tasks Scheduling
- Alien Dictionary

17. 0/1 Knapsack

Usage: This technique is used to solve optimization problems. Use this technique to select
elements that give maximum profit from a given set with a limitation on capacity and that
each element can only be picked once.

DS Involved: Array, HashTable

Sample Problems:
- Equal Subset Sum Partition
- Minimum Subset Sum Difference

Complete Switching Bootcamp | 49


18. Fibonacci Numbers
Usage: Use this technique to solve problems that follow the Fibonacci numbers sequence,
i.e., every subsequent number is calculated from the last few numbers.

DS Involved: Array, HashTable

Sample Problems:
- Staircase
- House Thief

19. Palindromic Subsequence


Usage: This technique is used to solve optimization problems related to palindromic
sequences or strings.

DS Involved: Array, HashTable

Sample Problems:
- Longest Palindromic Subsequence
- Minimum Deletions in a String to make it a Palindrome

20. Longest Common Substring


Usage: Use this technique to find the optimal part of a string/sequence or set of
strings/sequences.

DS Involved: Array, HashTable

Sample Problems:
- Maximum Sum Increasing Subsequence
- Edit Distance

50 | Pratham Kohli
More questions and Resources to Master DSA problem and
Patterns from:
Arrays:
1. Top 50 Array Coding Problems for Interviews
2. Solve Array problems from Striver’s sheet

Sliding Window :
1. Sliding Window algorithm template to solve all the Leetcode substring search
problem
2. Sliding window substring problems template

Binary Search:

I love the following doc, this will clear a lot of your Binary Search doubts, on when to take
what limits, how to take mid, when to increase / decrease interval!!
This is explained via a problem statement, do give it a read!!

Problem Statement:
https://leetcode.com/problems/furthest-building-you-can-reach/ :

1642. Furthest Building You Can Reach

You are given an integer array heights representing the heights of buildings, some bricks, and
some ladders.

You start your journey from building 0 and move to the next building by possibly using
bricks or ladders.

While moving from building i to building i+1 (0-indexed),

● If the current building's height is greater than or equal to the next building's height,
you do not need a ladder or bricks.
● If the current building's height is less than the next building's height, you can either
use one ladder or (h[i+1] - h[i]) bricks.

Return the furthest building index (0-indexed) you can reach if you use the given ladders and
bricks optimally.

Example 1:

Complete Switching Bootcamp | 51


Input: heights = [4,2,7,6,9,14,12], bricks = 5, ladders = 1

Output: 4

Explanation: Starting at building 0, you can follow these steps:

- Go to building 1 without using ladders nor bricks since 4 >= 2.

- Go to building 2 using 5 bricks. You must use either bricks or ladders because 2 < 7.

- Go to building 3 without using ladders nor bricks since 7 >= 6.

- Go to building 4 using your only ladder. You must use either bricks or ladders because 6 <
9.

It is impossible to go beyond building 4 because you do not have any more bricks or ladders.

Example 2:

Input: heights = [4,12,2,7,3,18,20,3,19], bricks = 10, ladders = 2

Output: 7

52 | Pratham Kohli
Example 3:

Input: heights = [14,3,19,3], bricks = 17, ladders = 0

Output: 3

Constraints:

● 1 <= heights.length <= 105


● 1 <= heights[i] <= 106
● 0 <= bricks <= 109
● 0 <= ladders <= heights.length

Solution:

Binary search's details easily confuse many programmers, so many become tempted to resort
to poor practices such as Programming by Permutation. With that in mind, I'm going to walk
you through a methodical way of approaching this problem that also applies to other binary
search problems. If you’re already confident with binary search and don't want to walk
through it in this level of detail, then you can skip straight to the pseudocode, or ideally, go
away and try and code it up on your own. Otherwise, I recommend following really carefully,
as this process really does help.

The importance of being able to methodically design and implement a binary search cannot
be understated. You'll almost certainly encounter it in multiple interviews. Focus firstly on
your accuracy and then work on your coding speed. While coding fast and correctly is the
ideal, keep in mind that accuracy is still worth more than speed. Buggy code is bad, no matter
how quickly you wrote it.

These are the questions we'll be answering and then putting into code.

1. What is the target item, value, and type?


2. What bounds must the target item be within?
3. What can we conclude when isReachable(mid) returns true ("yes")?
4. What can we conclude when isReachable(mid) returns false ("no") ?
5. How do we know when we've found the target item?
6. Which calculation for mid should we use?

Step 1: What is the target item, value, and type?

We want to know which building in the heights array (i.e., not a climb distance) is the
final-reachable-building. Buildings are identified by indexes in the array; therefore, we're
looking for the index in heights that corresponds to the final-reachable-building. It might

Complete Switching Bootcamp | 53


sound obvious in this case, but it's always important to pinpoint whether we're looking for an
index, between two indexes, or something else entirely.

Step 2: What bounds must the target item be within?

The highest possible index for the final-reachable-building is heights.length - 1 (i.e. the last
building in heights). In the worst case, the only building we’ll be able to reach is the building
at index 0 (which we can always reach). Therefore, the answer could be anywhere from 0 to
heights.length - 1, inclusive of both of these endpoints. In the binary search code, this will be:

lo = 0
hi = heights.length - 1

Notice that we haven't used hi = heights.length or lo = -1, or anything else like that. People
are sometimes tempted to put that stuff in to "cover edge cases", handle inclusive vs.
exclusive endpoints, etc., without fully understanding what they were trying to achieve with
it. It's generally easiest to set lo to represent the lowest possible position of the target and hi
to be the highest possible position.

Step 3: How do we know when we found the target?

Often in a binary search, we immediately know when we've found the answer. For example,
if the problem was to search for 12 in a sorted array, then as soon as the value at mid is 12,
we can return true.

For this problem, though, we can't do that. If the value of isReachable(mid) is true, then it is
possible that it is indeed the final-reachable-building, but it is also very possible that the
final-reachable-building is further to the right. Because of this, we should instead shrink the
search space down to length-one (i.e., to where lo = hi) and then determine whether or not
that one item is the one we want. In this case, we know that the target definitely exists, so as
soon as the search space is of length-one, the index in it is for the final-reachable-building.

With that, this is what we have so far.

lo = 0
hi = heights.length - 1
while lo is less than hi:
Details here are still to be decided
return lo

Don't attempt to keep track of the highest true so far using an additional variable. It's
unnecessary, as we can simply shrink the search space down so that in the end, it only
contains the final reachable value.

54 | Pratham Kohli
Step 4: What can we conclude when isReachable(mid) returns true?

If isReachable(mid) returns true, then we know that the building at mid is reachable. We're no
longer interested in any of the buildings before mid, as they can’t possibly be the
final-reachable-building (as mid is further than them).

We don't know whether or not the building at mid + 1 is reachable, though, and nor should we
check right now.

Remembering that lo and hi represent the boundaries of where the final-reachable-building


could be, we should set lo = mid. This means that the building at mid is now the lowest
building in the search range.

Setting lo = mid + 1 would be incorrect here because it’s possible that all buildings from mid
+ 1 onwards are not reachable, and that we’ve just chopped the final-reachable-building out
of the search space (remember, we want to shrink the search space down to a single index;
the index of the final-reachable-building).

Step 5: What can we conclude when isReachable(mid) returns false?

If isReachable(mid) returns false, then we know that the building at mid is not reachable.
This means that none of the buildings after mid could possibly be reachable either. Therefore,
the final reachable building must be before mid; in other words, the highest possible
candidate now is mid - 1. So we should set hi = mid - 1.

A common mistake here is to simply use hi = mid so as to avoid having to reason about
whether or not to put the - 1. This is very problematic, though, as whenever you’re doing a
binary search with the while lo is less than hi condition (i.e., reducing the search space to
length-one), you must have at least one of hi = mid - 1 and lo = mid + 1. If you have neither
of these, then your algorithm might infinitely loop once the search space is of length-two.

Updating our code with the latest details we've determined, here is what we have so far.

lo = 0
hi = heights.length - 1
while lo is less than hi:
mid = [formula to be decided]
if building at mid is reachable:
lo = mid
else:
hi = mid - 1
return lo

Step 6: Which calculation for mid should we use?

Complete Switching Bootcamp | 55


On an odd-lengthed search space, identifying the midpoint is straightforward. On
even-lengthed search spaces, though, we have two possible midpoints. The final step of the
binary search algorithm design process is to decide whether it is the lower or higher midpoint
that should be used.

Your decision should be based on how you are updating hi and lo (i.e., lo = mid and hi = mid
- 1 for the algorithm we've designed here). Think about what happens once the search space
is of length-two. You must ensure that the search space is guaranteed to be shrunk down to
length-one, regardless of which condition is executed. If you take the lower middle, it will
sometimes infinitely loop. And if you take the upper middle, it will be guaranteed to shrink
the search space down to one.

So, it is the upper-middle that we want.

The short rule to remember is: if you used hi = mid - 1, then use the higher midpoint. If you
used lo = mid + 1, then use the lower midpoint. If you used both of these, then you can use
either midpoint. If you didn’t use either (i.e., you have lo = mid and hi = mid), then,
unfortunately, your code is buggy, and you won’t be able to guarantee convergence.

Whenever we want the upper middle, we use either mid = (lo + hi + 1) / 2 or mid = lo + (hi -
lo + 1) / 2. These formulas ensure that on even-lengthed search spaces, the upper middle is
chosen and on odd-lengthed search spaces, the actual middle is chosen.

This completes our binary search algorithm.

lo = 0
hi = heights.length - 1
while lo is less than hi:
mid = lo + (hi - lo + 1) / 2
if building at mid is reachable:
lo = mid
else:
hi = mid - 1
return lo

JAVA SOLUTION for problem:


https://leetcode.com/problems/furthest-building-you-can-reach/

class Solution {

public int furthestBuilding(int[] heights, int bricks, int ladders) {


// Do a binary search on the heights array to find the final reachable building.
int lo = 0;
int hi = heights.length - 1;
while (lo < hi) {

56 | Pratham Kohli
int mid = lo + (hi - lo + 1) / 2;
if (isReachable(mid, heights, bricks, ladders)) {
lo = mid;
} else {
hi = mid - 1;
}
}
return hi; // Note that return lo would be equivalent.
}

private boolean isReachable(int buildingIndex, int[] heights, int bricks, int ladders) {
// Make a list of all the climbs we need to do to reach buildingIndex.
List<Integer> climbs = new ArrayList<>();
for (int i = 0; i < buildingIndex; i++) {
int h1 = heights[i];
int h2 = heights[i + 1];
if (h2 <= h1) {
continue;
}
climbs.add(h2 - h1);
}
Collections.sort(climbs);

// And now determine whether or not all of these climbs can be covered with the
// given bricks and ladders.
for (int climb : climbs) {
// If there are bricks left, use those.
if (climb <= bricks) {
bricks -= climb;
// Otherwise, you'll have to use a ladder.
} else if (ladders >= 1) {
ladders -= 1;
// And if there are no ladders either, we can't reach buildingIndex.
} else {
return false;
}
}
return true;
}
}

Complete Switching Bootcamp | 57


More Links for Binary Search:
1. Binary Search for Beginners
2. [Python] Powerful Ultimate Binary Search Template. Solved many problems
3. Binary Search 101

Stacks and Queues :


Stacks and Queues are mostly doable, except the monotonic stack questions which require
practice to become familiar with it

1. Monotonic Queue Summary


2. Applications of Monotonous Increasing stack

Must Do question : LRU Cache ( very frequently asked in interviews) : link

Two pointers :
1. General summary of what kind of problem can/ cannot solved by Two Pointers

Bit Manipulation Patterns:


1. All Types of Patterns for Bits Manipulations and How to use it: link

Recursion:
1. Recursive Practice Problems with Solutions

Backtracking :
1. Backtracking Summary and general template to solve many problems
2. A general approach to backtracking problems in C++
3. A general approach to backtracking problems in Java
4. Backtracking: Practice Problems and Interview Questions

58 | Pratham Kohli
Dynamic Programming :
Suggested Playlist:

1. Dynamic Programming by Aditya Verma : link

Link to Handwritten Notes of the above Playlist : link1 , link2 , link3

or

2. Dynamic Programming by Striver : link

Questions to Solve:

1. DP for Beginners [Problems | Patterns | Sample Solutions]


2. DP Patterns

Bitmasks:
1. Dynamic Programming with Bitmasks

GRAPHS:
Suggested Playlist:

1. Graph by Striver: link

Link to Handwritten Notes of the above Playlist : link1, link2

Questions to Solve:

1. Solve Graph questions from Striver Sheet: link

Complete Switching Bootcamp | 59


TRIES:
Link for Understanding Tries : link

Practise the following problems:

● Implement Trie (Prefix Tree)


● Longest Common Prefix
● Search Suggestions System
● Longest Word in Dictionary
● Top K Frequent Words
● Design Add and Search Words Data Structure
● Implement Magic Dictionary
● Replace Words
● Word Search II
● Stream of Characters

String Manipulation
1. Top 21 String Programming Interview Questions for Beginners and Experienced
Developers

Greedy Algorithms -
1. Top 7 Greedy Algorithm Problems

Segment Trees:
1. Segment Trees

60 | Pratham Kohli
Now what is next ?
Start practising problems everyday

- You can glance over Striver’s sheet once for more questions on Arrays, and other
concepts that are mentioned in the sheet: link
- Do the daily Leetcode streak to keep in touch with problems and test your ability to
tackle any problem ( any pattern ) to see how your brain detects them
- This will come with practice
- Give Contest
- Why ?
- A timed environment is a best replica of your interview, solve contests and try
to do problems as quickly as possible
- This will help in Online Assessments and even in Interviews
- More Resources:
- Grind 75 : [ link ]
- Algo monster: [ link ]
- For the daily problems,
- Keep a timer, give at max 40 mins to questions and then move on to see
discuss sections
- Mark this problem and note it in a list, come back to it after a week, really
necessary as if the same problem comes in interview but you don’t remember
on how to tackle it properly, it can cost you
- Also in revision, these are the problems that we need to go over, the ones we
were not able to do in the 1st attempt. ( as mostly the ones we were able to do
naturally, we should be able to do again if we see something similar)

Complete Switching Bootcamp | 61


𝟭𝟬 𝗚𝗼𝗹𝗱𝗲𝗻 𝗥𝘂𝗹𝗲𝘀 𝗳𝗼𝗿 𝗦𝗼𝗹𝘃𝗶𝗻𝗴 𝗮 𝗖𝗼𝗱𝗶𝗻𝗴 𝗤𝘂𝗲𝘀𝘁𝗶𝗼𝗻 𝗶𝗻 𝗮𝗻 𝐈𝐧𝐭𝐞𝐫𝐯𝐢𝐞𝐰

1. If we are dealing with top/maximum/minimum/closest ‘K' elements among 'N' elements,


we will be using a Heap.

2. If the given input is a sorted array or a list, we will either be using Binary Search or the
Two Pointers.

3. If we need to try all combinations (or permutations) of the input, we can either use
Backtracking or Breadth First Search.

4. Most of the questions related to Trees or Graphs can be solved either through Breadth First
Search or Depth First Search.

5. Every recursive solution can be converted to an iterative solution using a Stack.

6. For a problem involving arrays, if there exists a solution in O(n^2)time and O(1) space,
there must exist two other solutions: 1) Using a HashMap or a Set for O(n) time and O(n)
space, 2) Using sorting for O(n log n) time and O(1) space.

7. If a problem is asking for optimization (e.g., maximisation or minimization), we will be


using Dynamic Programming.

8. If we need to find some common substring among a set of strings, we will be using a
HashMap or a Trie.

9. If we need to search/manipulate a bunch of strings, Trie will be the best data structure.

10. If the problem is related to a LinkedList and we can't use extra space, then use the Fast &
Slow Pointer approach.

62 | Pratham Kohli
Phase 4 : System Design
[ Low Level Design ]

We will start with the basics : OOPs

What are OOP(s) Principles ?


Object-oriented programming focuses on objects made up of both data (fields) and code
(properties or attributes). Using OOP, programmers can create classes in order to iteratively
reuse code, with the same set of “instructions” being sent to different objects, rather than
coding each operation from scratch each time. This works particularly well for large team
projects where states change often.

List of OOP concepts:


1. Abstraction
2. Encapsulation
3. Inheritance
4. Polymorphism

Read more here :


Explanation of OOPs concepts with examples - link

What are SOLID Design Principles?

SOLID design principles represent a set of guidelines that helps us to avoid a bad design
when designing and developing software. The design principles are associated to Robert
Martin who gathered them in "Agile Software Development: Principles, Patterns, and
Practices". According to Robert Martin there are 3 important characteristics of a bad design
that should be avoided:

● Rigidity - It is hard to change because every change affects too many other parts of
the system.
● Fragility - When you make a change, unexpected parts of the system break.
● Immobility - It is hard to reuse in another application because it cannot be
disentangled from the current application.

S.O.L.I.D - is a acronym based on name of the design principles in the collection:

● Single Responsibility Principle


● Open Close Principle
● Liskov's Substitution Principle
● Interface Segregation Principle

Complete Switching Bootcamp | 63


● Dependency Inversion Principle

Single Responsibility Principle

● A class should have only one reason to change.

In this context a responsibility is considered to be one reason to change. This principle states
that if we have 2 reasons to change for a class, we have to split the functionality in two
classes. Each class will handle only one responsibility and on future if we need to make one
change we are going to make it in the class which handle it. When we need to make a change
in a class having more responsibilities the change might affect the other functionality of the
classes.

Single Responsibility Principle was introduced Tom DeMarco in his book Structured
Analysis and Systems Specification, 1979. Robert Martin reinterpreted the concept and
defined the responsibility as a reason to change.

Open Close Principle

● Software entities like classes, modules and functions should be open for extension but
closed for modifications.

OPC is a generic principle. You can consider it when writing your classes to make sure that
when you need to extend their behavior you don't have to change the class but to extend it.
The same principle can be applied for modules, packages, libraries. If you have a library
containing a set of classes there are many reasons for which you'll prefer to extend it without
changing the code that was already written (backward compatibility, regression testing, ').
This is why we have to make sure our modules follow Open Closed Principle.

When referring to the classes Open Close Principle can be ensured by use of Abstract Classes
and concrete classes for implementing their behavior. This will enforce having Concrete
Classes extending Abstract Classes instead of changing them. Some particular cases of this
are Template Pattern and Strategy Pattern.

Liskov's Substitution Principle

● Derived types must be completely substitutable for their base types.

This principle is just an extension of the Open Close Principle in terms of behavior meaning
that we must make sure that new derived classes are extending the base classes without
changing their behavior. The new derived classes should be able to replace the base classes
without any change in the code.

64 | Pratham Kohli
Liskov's Substitution Principle was introduced by Barbara Liskov in a 1987 Conference on
Object Oriented Programming Systems Languages and Applications, in Data abstraction and
hierarchy

Interface Segregation Principle

● Clients should not be forced to depend upon interfaces that they don't use.

This principle teaches us to take care how we write our interfaces. When we write our
interfaces we should take care to add only methods that should be there. If we add methods
that should not be there the classes implementing the interface will have to implement those
methods as well. For example if we create an interface called Worker and add a method lunch
break, all the workers will have to implement it. What if the worker is a robot?

As a conclusion Interfaces containing methods that are not specific to it are called polluted or
fat interfaces. We should avoid them.

Dependency Inversion Principle

● High-level modules should not depend on low-level modules. Both should depend on
abstractions.
● Abstractions should not depend on details. Details should depend on abstractions.

The Dependency Inversion Principle states that we should decouple high level modules from
low level modules, introducing an abstraction layer between the high level classes and low
level classes. Furthermore it inverts the dependency: instead of writing our abstractions based
on details, we should write the details based on abstractions.

Dependency Inversion or Inversion of Control are better known terms referring to the way in
which the dependencies are realised. In the classical way when a software module(class,
framework, ') needs some other module, it initialises and holds a direct reference to it. This
will make the 2 modules tight coupled. In order to decouple them the first module will
provide a hook(a property, parameter, ') and an external module controlling the dependencies
will inject the reference to the second one.

By applying the Dependency Inversion the modules can be easily changed by other modules
just changing the dependency module. Factories and Abstract Factories can be used as
dependency frameworks, but there are specialized frameworks for that, known as Inversion of
Control Container.

Important: Read more about SOLID Principles with Visualisations and examples via this
Medium Blog: link

Complete Switching Bootcamp | 65


Design Patterns to Read and Understand:

After establishing are basic pillars of OOPs and SOLID Principles, time to understand some
design patterns.

Why Design Patterns ?


- In the Software Engineering domain, some problems are seen often, to tackle them
gracefully patterns were built.

Here is a list of patterns that is required for Interviews:

1. Strategy Pattern
2. Observer Pattern
3. Decorator Pattern
4. Factory Pattern
5. Abstract factory Pattern
6. Singleton Pattern[ Also Read on how to make it thread safe]
7. Adapter Pattern
8. Facade Pattern
9. Chain of Responsibility Pattern
10. Memento Design Pattern
11. Composite Design Pattern
12. State Design Pattern.

From where to Read in depth?

66 | Pratham Kohli
Recommended Sources:

1. Head First Design Patterns Book - Either Purchase, or simply download online [ just
do a google search ]

2. Tutorials Points : link


3. Refactoring Guru
4. If interested in seeing videos for the patterns instead, here is a playlist of the patterns
as explained in Head First Design Book: link

How to Revise Patterns?

Here are my notes for Revision: link, but recommended to write your own notes as well!

Low Level Design

- This deals with actual implementation of the system or problem


- We are majorly concerned with 2 UML Diagrams i.e. Use case diagram and Class
Diagram for our Interviews

Complete Switching Bootcamp | 67


How to approach an LLD Problem ?
Blueprint:
1. Understand the problem
a. Clarify all requirements
b. Whatever comes to your mind, write everything down
c. Keep adding all use cases you can think of
d. One trick to think of all use cases is to think of the Activity flow that may
happen.
Example: If I have to think of Use cases for a Movie Booking System, I will
think of all the actions I have to perform in order to book a movie
- I open the app, I have an option to select a location
- As per my location, I am shown Movies
- When I select a movie, I see multiple dates when I can book a ticket
- On clicking a date, I see multiple theatres with multiple shows in each
with different times
- On clicking a show, I should be able to select seats, then make
payment, get my booking details, ticket emailed to me and so on.
- I hope you get the picture
2. After writing down requirements, what we need to do next is identify Actors and use
cases for actors
a. Trick to do this is, analyse whatever use case you wrote
b. The Noun generally points to an Actor
c. The Verb generally points to a function, the actor performs
3. Now after we identify the actors, use cases, write them down separately.
a. Option step - We can make the use case diagram for better understanding on
what functions should be invoked by different actors -> Thus make a different
class for that function
b. Example - Search functionality in a Library System should be available to
both the Librarian and the Issuer, so good idea to have a separate Class for
Search and have an Object of Search class in both the Librarian and Issuer
class
c. Creating a use case diagram also helps define the system boundary, on what all
we will discuss and what all lies in the system
4. Next step is to start coding…duh!!
a. In LLD we need to generally write class signatures meaning define a class,
define it’s attributes and write function signatures for the class
5. The way to code is to start with primary entities and keep defining all sub entities that
we encounter, while keeping in mind our OOPs, SOLID Principles that we read
above.
6. Adding Patterns while implementing/ writing code is always helpful
- Some Interviewers are on the look out to see if you mention the pattern names
or not and if you keep in mind these patterns while implementing / writing
code

68 | Pratham Kohli
Videos to watch to understand how to approach Problems:

1. How to Approach an LLD Problem (using Hotel Management System example) ? link
2. LLD Code Implementation (using Hotel Management System example) : link
3. Library Management System [ Approach and Use case diagram ] : link
4. Library Management System [ Code ] : link
5. Ticket Booking System [ Movie / Event booking] : link
6. E-commerce website LLD : link
7. ATM LLD : link
8. Chess LLD : link
9. Parking Lot : link
10. Stack Overflow LLD : link

How to implement end to end code ?


1. IMPORTANT: For more LLD problems, examples, explanation, Working code (end
to end), go through this playlist on Youtube by Shrayansh Jain: link to playlist
2. Low Level Design Primer : link
a. This repo contains detailed solutions to a variety of low-level design problems,
giving a practical approach to solving similar problems.
3. More solutions in Grokking the Object Oriented Design interview : Free version
pdf can be found easily on internet
4. Now it is Time to practise all the problems by yourself !!

Machine Coding Rounds

The machine-coding round is a major part of the interview process when you are targeting
startups (or Uber )

This is the same as LLD but now you need to implement a running code, end to end in the
interview or take home assignment.

Extra Resources for Machine Coding Round:

WorkAt Tech Article on Machine Coding:


https://workat.tech/machine-coding/article/how-to-ace-machine-coding-round-hi8lnpp8tlmo

This is a good manual and provides valuable insights and strategies for acing machine coding
rounds.
Other resources of end to end code are present in the Github Repo above!

Complete Switching Bootcamp | 69


Types of problems-
There are generally 4 types of problems in Machine Coding in my understanding, I like to
categorise them as follows-

● CRUD questions - Library Management, Parking Lot, E-Commerce, Splitwise, Event


Scheduling App
● Strategy Type - Elevator System, Food Delivery App (this also falls in CRUD
questions list), Split Wise with Reducing the transactions (this also falls in CRUD
questions list)
● Game Questions - Snake and Ladder, Chess, Ludo
● State Based - Vending Machine.
● Multithreading - Print even and odd from different threads, Queue like Kafka.

Preparation Tips
Solve at least 2 of each type and you should be good. Take following points into
consideration while practising

● Find complete problem statements from anywhere on google.


● Start a timer and assume you have to complete the task in 1 hr only
○ Make sure you behave as if you are in an interview
○ Create a README file and write all the discussion that you want to convey to
the interviewer
○ Code as fast as you can.
○ Make a habit of error handling and proper logging.
○ You may explore a few shortcuts that can help you reduce coding time during
the interview. Like generic data types etc.
○ At each step make sure your code is working, so that in case you run out of
time; whatever code you have, is working perfectly fine.
○ Keep writing driver files in parallel.

Learn these
Try to use evergreen design patterns in your solution like - Singleton pattern, factory pattern,
adapter pattern, strategy pattern, chain of responsibility pattern, memento design pattern,
composite design pattern, observer pattern, state design pattern.

How to approach any problem


● Write down the requirements
● Identify the entities/models
● find relation amongst them
● Clarify the service layer and what params might be required (This will help you in
case you might be missing some properties in your models)
● Start by creating all models
● Create Dao Layer.

70 | Pratham Kohli
● Create service layer
● Identify special design that fits here - strategy design, state design, etc etc.

What else to do ?

1. LeetCode Discussion, GeeksforGeeks, Glassdoor:


Thoroughly go through previously asked questions from these platforms to gain
insight into the types of problems asked.

2. Hands-On Coding Practice:


Actively code solutions for the problem statements, making a solid grasp of the
concepts and improving the way I code.

3. Peer Discussions ( If possible have a buddy you can practise this with):
Connected with friends for in-depth discussions on code optimization strategies,
debate on the pros and cons of different approaches to improve your problem-solving
skills.

Complete Switching Bootcamp | 71


Phase 5 - High Level Design
High-level design or HLD refers to the overall system, a design that consists description of
the system architecture and design and is a generic system design that includes:
● System architecture
● Database design
● Brief description of systems, services, platforms, and relationships among modules.

Must Do:
Start with Gaurav Sen’s basic playlist to get familiar with terms: link to the playlist
Terms to become familiar with:
- Horizontal, Vertical Scaling
- Load balancing
- Consistent Hashing
- Message Queue
- Microservice Architecture
- Database Sharding
- Distributed Cache
- What is an API and How to Design it ?
- Capacity Planning and Estimation
- CDNs ( Content Delivery Systems)
- Single Point of Failure
- Event Driven System
- NoSQL Databases
- Database Scaling
- Data Replication, Distributed Consensus
- Cascading Failures
- Cloud Computing
- CAP Theorem
- Data Consistency
- Monoliths vs Microservices

All these will be explained in the playlist here.

Watch carefully, make notes for revision later on.

System Design Primer: https://github.com/donnemartin/system-design-primer is a good


starting point too, if you like reading instead.
Keep it handy.

72 | Pratham Kohli
But I would recommend you 1st watch Gaurav Sen’s playlist, then read Alex Xu’s book and
later read the System Design Primer.

Purchase / Download this book:


- System Design Interview: An Insider's Guide – Volume by Alex Xu Purchase link
- This is very beginner friendly, and is a good start.
- It will clear your understanding of basic concepts
- Give you a starting point on how to tackle problems.

Complete Switching Bootcamp | 73


Blueprint to tackle HLD Problems:
1. Understand the Problem Statement
a. Clarify Requirements
b. Don’t assume anything, clarify your assumptions
c. Ask questions as many as required
d. Write down functional requirements
e. write down non-functional requirements
f. only then move to next section
2. Estimate the Volume of Data our system is to Handle, make some rough calculations
3. Create a rough design with basic services and basic building blocks.
- Keep the interviewer engaged with your design
4. Now Deep Dive into services the Interviewer is interested in
- The Interviewer always has a couple of services they have in mind, the ones
they want to discuss
- They always have a couple of data points, like some critical functions or some
critical edge cases and they keep on evaluating you on those, that did you
discuss those or not
- So keep speaking while you brainstorm so that they keep getting all the data
points they need to evaluate you

- Videos of Code karle (MUST)

1. Database Design Tips | Choosing the Best Database in a System Design Interview :
link
2. Google Maps: link
3. Video Streaming Platform ( Netflix, prime, Hulu) [ Imp ] : link
4. Twitter / Read - Heavy System : link
5. Social Network Design [Facebook / Instagram / Linkedin]: link
6. Cab Booking SYstem [ Uber / Ola ] : link
7. Design E-commerce Application [ Amazon / Flipkart ] : link
8. Design a Chat Application [ Whatsapp / Facebook Messenger ] : link
9. Video Conference Application [ Zoom / Whatsapp Video / Facebook Video Call ] :
link
10. URL Shortening Service : link
11. Hotel Booking System [ Airbnb / Booking.com ] : link
12. Notification Service System [ that is very Scalable] : link
13. System Design Tips and Tricks : link

Playlist link: link

- More solutions for Design problems can be found in Grokking the Design interview : Free
version pdf can be found easily on internet

74 | Pratham Kohli
After going through the above content, about two to three times, you should have a really
good catch on what to expect and how to think.
If this feels daunting, don’t worry, everybody feels the same.
Practise the above at least two to three times to become fluent in the way you should tackle
the System Design problems

- Alex Xu book vol 2 - This one is advanced and is recommended after all basics and basic
designs are clear.

More Resources if you want to build more knowledge, generally not required unless you are
applying for a Senior role:
1. System Design Interview | Step by Step Guide : link
2. Top K Problems ( heavy Hitters ) : link
3. Distributed Cache: link
4. Rate Limiting : link
5. Notification Service: link
6. Distributed Message Queue: link

- Github Repo with more videos, blogs to tackle more System Design problems: link
[Repo Name: awesome-system-design-resources ]

To build a Deeper Understanding of System Design, not only for Interviews but for you
Career as well, check this:
- Designing Data Intensive applications : Link to purchase

Complete Switching Bootcamp | 75


25 𝐑𝐮𝐥𝐞𝐬 𝐭𝐨 keep in mind while 𝐚𝐧𝐬𝐰𝐞𝐫ing 𝐢𝐧 𝐚 𝐒𝐲𝐬𝐭𝐞𝐦 𝐃𝐞𝐬𝐢𝐠𝐧 𝐈𝐧𝐭𝐞𝐫𝐯𝐢𝐞𝐰

1. If we are dealing with a read-heavy system, it's good to consider using a Cache.

2. If we need low latency in the system, it's good to consider using a Cache & CDN.

3. If we are dealing with a write-heavy system, it's good to use a Message Queue for Async
processing

4. If we need a system to be ACID complaint, we should go for RDBMS or SQL Database

5. If data is unstructured & doesn't require ACID properties, we should go for NO-SQL
Database

6. If the system has complex data in the form of videos, images, files etc, we should go for
Blob/Object storage

7. If the system requires complex pre-computation like a news feed, we should use a Message
Queue & Cache

8. If the system requires searching data in high volume, we should consider using a search
index, tries or a search engine like Elasticsearch

9. If the system requires to Scale SQL Database, we should consider using Database Sharding

10. If the system requires High Availability, Performance, & Throughput, we should consider
using a Load Balancer

11. If the system requires faster data delivery globally, reliability, high availability, &
performance, we should consider using a CDN

12. If the system has data with nodes, edges, and relationships like friend lists, & road
connections, we should consider using a Graph Database

13. If the system needs scaling of various components like servers, databases, etc, we should
consider using Horizontal Scaling

14. If the system requires high-performing database queries, we should use Database Indexes

15. If the system requires bulk job processing, we should consider using Batch Processing &
Message Queues

76 | Pratham Kohli
16. If the system requires reducing server load and preventing DOS attacks, we should use a
Rate Limiter

17. If the system has microservices, we should consider using an API Gateway
(Authentication, SSL Termination, Routing etc)

18. If the system has a single point of failure, we should implement Redundancy in that
component

19. If the system needs to be fault-tolerant, & durable, we should implement Data Replication
(creating multiple copies of data on different servers)

20. If the system needs user-to-user communication (bi-directional) in a fast way, we should
use Websockets

21. If the system needs the ability to detect failures in a distributed system, we should
implement a Heartbeat

22. If the system needs to ensure data integrity, we should use Checksum Algorithm

23. If the system needs to transfer data between various servers in a decentralised way, we
should go for the Gossip Protocol

24. If the system needs to scale servers with add/removal of nodes efficiently, with no
hotspots, we should implement Consistent Hashing

25. If the system needs anything to deal with a location like maps, nearby resources, we
should consider using Quadtree, Geohash, etc

Complete Switching Bootcamp | 77


Phase 6 Online Assessment
Tips:
Now I am hoping you must have practised a lot of DSA already, but avoid these trap:
- Normally when we see a question we tend to think and implement the most optimised
solution, which may not always be necessary in Online Assessments.
- Let me tell you what I mean.
- You see a problem, by seeing it you realise it is recursion.
- Next thought : I must use Dynamic Programming, so that the solution runs and does
not time out
- While the thought is good, implementing the DP version may be really hard and time
consuming, so check the constraints once, that do we really need the most optimised
version or a sub-optimised version also works ?
- Will my (2 ^ n) solution be accepted or do I need to make it O( n ^ 2) ?
- Will my O(n ^ 3 ) solution be accepted or do I really need to make it O(n) ?
How to determine what solution runs by looking at constraints ?
Here is a table to keep this in mind, I even had a sticky note of this table on my Monitor to
keep reminding me of this.
This even helps in Interviews!!!

How to Determine the solution of a problem by looking at its constraints?

Create a similar sticky note and paste it on your desk or wherever you sit and code day in and
day out!!

78 | Pratham Kohli
Detailed Breakdown:

Worst time Algorithmic


Constraints Examples
complexity solution

Recursion &
n ≤ 12 O(n!) Permutation 1….n
Backtracking

Recursion ,
All subsets of an
n ≤ 25 O(2n) Backtracking & Bit
array of size n
Manipulation

Dynamic
n ≤ 100 O(n4) 4Sum
Programming

All triangles with


Dynamic
n ≤ 500 O(n3) side length less
Programming
than n

Bubble Sort
Dynamic
(Slow
n ≤ 104 O(n2) Programming,
comparison-based
Graphs, Trees
sorting)

Complete Switching Bootcamp | 79


Sorting, Binary Merge Sort (Fast
n ≤ 106 O(n log n) Search, Divide and comparison-based
Conquer sorting)

Mathematical, Min and max of


n ≤ 108 O(n)
Greedy element

Mathematical,
n > 108 O(log n) or O(1) Binary Search
Greedy

80 | Pratham Kohli
Phase 7 - Behavioural Questions
Behavioural Questions and How to Answer Them:

Here is a list of tricky behavioural questions and sensible answers for the same.

These questions are very commonly asked in HR/behavioural/managerial rounds of


companies.

The reality is - in such rounds, it is important to sound diplomatic and politically correct.
Yes, it might sound like faking at times, but that is precisely what is needed.

As candidates, we definitely need to appear diplomatic and mature - specially for senior
positions (say 5+ years of experience). In these rounds, these soft skills matter way more than
your stellar coding rounds or design rounds.

0. The MOST IMPORTANT POINT - Resume DrillDown - Know your resume inside out.
Each and every word written in your resume can be questioned, it can be about your technical
skills, it can be about your hobbies or some award won by you. Be very very sure about
everything which you have written in your resume.

Even a HR person may ask questions about some fancy technical term(s) mentioned in your
skill set. You need to be ready to explain technical terms at a high level in 2-3 sentences. And
do not under-estimate the HR - I have personally known people working in HR who have a
background in Computer Science, and they are equally capable to grill you technically as
well.

1. Why do you want to quit your current job ?

Always frame the answer around things like - not learning anything new as the product is in a
saturated state, and unable to switch teams due to internal policies.

NEVER EVER talk about bad boss, politics etc - it will backfire bigtime.
We can also talk about your interest in the technology on which the company (who is
interviewing you) is working on.

In case your current company is recently acquired by another bigger company, then you can
always talk diplomatically about uncertainty in the environment in your company, several key
people leaving after acquisition, product being discontinued or put in maintenance mode etc.

2. Why do you want to join us ?

This is a similar question to the first one. Only difference is - for this question - we need to be
able to talk about 1-2 core products created by that company, the tech stack, and being able to
express our interest in the same. A sample answer maybe - I came to know about your
company because of product X, and I found it a very interesting concept.

Complete Switching Bootcamp | 81


I would love to get an opportunity to learn new things by working on this product. Also, use
this opportunity to try to get insights into any new features planned for the product in next
version.

Expressing interest in their technology is 50% job done for behavioural interviews.
MOST IMPORTANT PART - you must SOUND genuinely passionate when answering this
question. Practise rehearsing your lines in front of a mirror for this question - it may help.

3. What has been the biggest failure of your career till now ?
OR
What is the most critical feedback received from your boss in your entire career ?

Even if there is no such thing in reality (for people with say less than 3 years of experience),
do craft a reasonable story.
Talk about a time when you caused a major feature break, or a serious bug missed by you
which came through customer etc.
You can add that it caused a lot of chaos and I received very critical feedback from my boss
saying - "I did not expect this mistake from you".
Then talk about some corrective actions which you took, like enhancing test automation, or
getting into TDD mode etc and this helped in minimising future recurrences of such nature.
YES, talking about corrective actions is the most important part here.

If possible, support with data like - this enhancement in our process helped in preventing at
least 20 show stopper bugs from slipping in.

4. What does your typical day at work look like ?

Talk about your routine like - we have daily status meetings as first thing in the morning, then
we get onto development/debugging work, customer calls etc. Try to compress in 3-4
sentences at max.
Again, SOUND passionate and energetic when answering this question.

Here the interviewer may ask a follow-up question - what do you do in your free time at
work?
Possible answer - I prefer to read about other components of the product on which I have not
worked, and try to understand how to debug/troubleshoot those pieces of code.
Or else - my company has a huge repository of learning resources - I try to learn new things
etc

Basic motive is to showcase being eager to learn.

Another flavour of the above question - describe your current role.


In this case, give an overview of your current responsibilities, like I am developer/lead on this
project, working in a team of X number of people. I am responsible for X, Y and Z parts of
the project. Be honest about whether you are a hands-on coder or a hybrid of coding and team
management or a pure manager.

82 | Pratham Kohli
In case you are more on the management side, then be prepared to justify how you keep your
technical skills up-to-date.

5. Explain about your current product/project at a high level.

Here, we need to be very cautious. NO - never disclose any confidential details.


Try to explain the product using a high level architectural/block diagram (if the interviewer
allows) or else prepare a crisp 5-6 sentence description of the same.

6. What would you like to improve at your current workplace ?


OR
What do you dislike/hate at your current job/workplace ?

Again a trap - if you badmouth your current employer or use any words like hate or dislike, it
is guaranteed to go against you.

Talk about generic things like - sometimes code reviews take a long time due to senior
developers being busy - probably that can be streamlined.
Or say - we should invest more in enhancing the test automation infrastructure, which often
takes a backseat due to various constraints

Basically, try to stay around technical things, and avoid talking about poor cafeteria or no free
cab pickup-drop services etc.
The motive is to show your passion towards work related things and not focus on secondary
things like cafeteria or cabs or playgrounds etc.

7. Are you happy at your current job ?

This is also a big trap.


If you talk only about goody-goody positive things, then this question will be immediately
followed by - if you like your job, then why are you looking around for another job?

So, answer it diplomatically around point 1 of this post. Talk about good things like - I have
gotten to learn a lot.

If by any chance your current job is your first job - then definitely talk about things like - I
learnt the ways of working in industry in this job and hence this job will always be special for
me etc etc.

Then talk about negatives - again in a polished way - now the product has really evolved and
hence there is not much productive work to do other than customer support or maintenance
etc. Or else say that I have worked for a really long time on the same technology stack, and
want to expand my breadth by getting a chance to work on other technologies.

You may also borrow a few points listed in "Why do you want to quit your current job" above
in this post.

Complete Switching Bootcamp | 83


8. How would you react if you get to know that your boss is younger than you (or has
less years of experience than you) ?

This one is a make-or-break cultural fit question. Always answer diplomatically saying that
age/years etc are irrelevant for me. What matters for me is what can I learn from someone
irrespective of whether that person is junior or senior to me. I can learn a few things from my
boss for sure, and if it turns out that I am more experienced or older than my boss, then I am
sure I can be a valuable resource for my boss in terms of helping out with critical decision
making.
My experience will definitely be an asset for my boss in such cases.

Throw in examples of successful sports team of any sport which you like, there will be
several examples where the captain of a successful sports team is younger than a senior
important veteran player of the team. If you can give that type of analogy, your answer will
sound more genuine/natural.

9. What would you do if you find your senior or boss doing something unethical or
violating a company policy ?

Always talk about that you would gently point out to that person directly, and request that
person to follow the correct process. In case the violations continue, then I would like to
know about the violation reporting policy of your company.

Here, you can turn the interview around by cross-questioning your interviewer - "by the way,
can you give a brief insight into the policy violation reporting mechanism which exists in this
company ?"

10. Who has been your ideal/best boss ?

Talk about any boss who was a strong decision maker, always stood by the team, and openly
praised contributions by team members, and also clearly guided the team members towards
career growth.

Yes, such bosses are very rare in real life - but even if you did not have one such boss in your
real life, do talk along these lines.

Nobody is going to conduct an enquiry about whether you really had a boss who had all these
qualities or not.
Just be careful - not to take any person's name while talking about these qualities. If explicitly
asked, just politely say that I want to respect the privacy of that person, hence won't take any
names.

You can talk like - "Yes, I have been very fortunate to work under one/two such boss(es)
earlier in my career. I learnt a lot from him/her/them. I always found that person to be always
supportive of the team, and that person was the only person who actually told me the
difference between a Software Engineer and a Senior Software Engineer in clear measurable
terms etc etc."

84 | Pratham Kohli
11. Describe the worst boss you have ever worked under.

NEVER NEVER EVER start describing that one bad boss you may have encountered. Be
very very diplomatic here.
One slip of tongue in answering this one - and you are already rejected as "being a poor
culture fit".

You can say something like this and create a reasonable story like this - "Well, nobody is
perfect - everyone is good in some things and not so good in other things. Regarding my
bosses, I am not able to think of anyone who can be labelled as worst as such. I learnt
something or other from each and every boss I worked under.
If I have to explicitly describe the shortcomings of any particular boss, then I will not exactly
call it a shortcoming, but I feel it was his extradordinary passion towards his work. I had a
boss who often used to get so carried away in work when working with us in
brainstorming/discussion sessions that we would often end up getting very delayed for lunch.
Initially I found it irritating, but with the passage of time, I realised that he was a person of
extreme dedication and passion towards his work. The more I worked with him, the more I
learnt from him.
And coming to this lunch time issue, I hesitatingly brought up this point once with him
privately, and he happily agreed to have working lunch in such cases.

So, in a nutshell - there are no bad bosses - it is just that their way of working/thinking is
drastically different from ours."

Prepare 2-3 stories of this type, just in case the interviewer adds a follow-up like - "any other
irritating bosses you worked under".

So, the whole idea is to mould a highly negative conversation towards a positive direction.

12. If you have 5+ years experience and mention that you yourself are an interviewer -
then you may be asked to describe your strategy of taking interviews - stuff like what
type of questions you ask, and what are you trying to judge based on that question.

In such a case, be ready with 2-3 questions and present them as your pet questions.
Be ready with justification like - by asking this tricky coding problem, I try to judge up to
what extent the candidate can think, can the candidate come up with different approaches etc.
By asking this question Y - I try to get a feel as to whether the candidate will be a decent
cultural fit in our company or not.

Be prepared for a follow-up like - "if you have to look at your own interview rounds going on
right now in this company, what do you think the interviewers were trying to judge about
you."
Try to answer on similar lines staying close to job description. You can say - "as this job is for
a Senior Software Engineer, so it is expected that the interviewer would like to be fully
convinced about my coding abilities. So, it is quite natural that I was asked X, Y, Z. In the
current round, I believe you are trying to take a call as to whether people would like to work

Complete Switching Bootcamp | 85


with me as a teammate, and hence you are trying your best not to err in judging me as a
person."

13. What is your greatest weakness ?


No, NO, NO - please do not talk about being impatient or pushing your team hard etc etc.
These are all very very well-known answers.

Talk about something more genuine and possibly not related to work - I am not so good at
remembering road directions, or maybe people whose first/second language is not English
may feel that occasionally I speak too fast.

But be prepared to answer - what are you doing to overcome this weakness ?
Possible answers to above examples may be - I am trying to get better at remembering road
directions by observing the landmarks more closely when I pass through any road
or
I consciously try to speak at a slower pace and in a neutral accent when interacting with
people whose first/second language may not be English. I am actually trying to learn more
about different cultures across the globe to be sensitive to their requirements.
If you talk about culture, be prepared to talk about a few interesting facts about the culture of
a few countries - e.g. using your left hand to give/take something in Asian countries may be
considered offensive, tipping is not considered good in some countries but is a natural
expectation in some other countries etc.

Being culturally sensitive is very very important for working in any MNC.

14. Why should we hire you?


OR
Why do you think you are a good fit for this role/job ?

Again a cliche question. Just talk about your passion for the role, talk about how your skills
are a perfect match for this role, definitely do highlight any not-so-common achievement of
yours (may be you have been a state level player, or maybe you appeared on a TV show - use
it to market your people skills, maybe you won multiple scholarships in your career).
And at the end say - I strongly believe these qualities of mine make me a worthy candidate
for this role.
Mark the wording - worthy - NOT perfect. Be very cautious as to NOT to sound arrogant.

15. [For fresh graduates/postgraduates only] What is your favourite subject and why ?
Be prepared with 2-3 names, because sometimes the interviewer may dig like - second
favourite subject ?

It is up to you whether you want to stay with routine subjects like Algorithms, Data
Structures etc or choose something else like Machine Learning, AI, Computer Graphics,
Computer Networks.
To answer the why part, NEVER EVER say things like because I always score good

86 | Pratham Kohli
grades/marks in this subject. You must be able to give a solid justification about the real
world applicability of the concepts taught in those subjects.

Some examples maybe - Data structures is the basic foundation of any software which we use
in real life.
Or
Machine learning is the basic concept behind so many useful features like recommended
news, purchase suggestions on e-commerce sites etc
Or
Computer Graphics is the very reason we get to see such amazing 3D/4D movies like <name
any of your favourite 3D/4D movies>

Also, a word of caution here - maybe you studied a subject named Advanced Algorithms or
say Advanced Concepts in Computer Networks - AVOID the word advanced if you can.
Because, using the word advanced may open up a pandora box and you may get bombarded
with several questions about concepts which you may not even have heard of !!

16. [For fresh graduates/postgraduates only] Which subject(s) do you HATE and why ?
This one is a very tricky question to answer, and you need a solid justification for the
same.

You should NEVER use the word HATE but say something like I am not very much
interested in this subject X.

X can be some compulsory elective course which is not exactly related to Computer Science
but is a part of your college/university curricullum. You can justify by saying that I have tried
very hard to understand where would I need to apply the concept taught in that subject, in the
field of software engineering.

By any chance, if your least favorite subject is related to Computer Science, then the only
possible way to justify it could be - I have never gotten any chance to practically apply the
concepts taught in that subject. There are indeed some subjects which are taught only
theoretically - if that is the case then you can give this justification.

Or even better - you can also say that there is no subject which I would put in the category of
dislike/hate, because every subject has its own importance.

17. [For fresh graduates/postgraduates only] Tell me about your major/degree project.
Be prepared to explain each and everything in thorough detail.
Try to structure your answer like this

Motive - what inspired you to take up this project? Justify with some real world application -
max 2-3 sentences
Initial exploration - what all did you read up about it - max 2-3 sentences
Implementation details - preferably a flow/block diagram (if possible), and 5-6 sentence
summary explanation

Complete Switching Bootcamp | 87


What did you learn from this task - I learnt how to actually implement a
Classifier/NeuralNetwork, I learnt a new tool/language named X etc. (2-3 sentences at max)

PAINFUL BUT REALLY HELPFUL WAY:


- Create answers for all the following questions, these are related to Leadership
principles, but can be used in every interview.
- Paste the list of questions in an excel and write an example with an answer against
every question.
- This is painful I know but trust me, it will save you hours later. Some questions may
be similar to what we saw in the questions above.
- Before every interview just glance through the questions and answers you wrote and
you are all set.
- Write examples in STAR Format :
S - Situation
T - Task
A - Action
R - Result

What is the STAR method?


The STAR method is an interview technique that gives you a straightforward format you can
use to tell a story by laying out the situation, task, action, and result.
■ Situation: Set the scene and give the necessary details of your example.
■ Task: Describe what your responsibility was in that situation.
■ Action: Explain exactly what steps you took to address it.
■ Result: Share what outcomes your actions achieved.

A STAR method example answer


“Tell me about a time when you had to be very strategic in order to meet all of your top
priorities.”
Your response might be (just, you know, don’t actually say “situation” and so forth):
■ Situation: “In my previous sales role, I was put in charge of the transition to an
entirely new customer relationship management (CRM) system—on top of handling
my daily sales calls and responsibilities.”
■ Task: “The goal was to have the migration to the new CRM database completed by
the start of Q3, without letting any of my own sales numbers slip below my targets.”
■ Action: “In order to do that, I had to be very careful about how I managed my time.
So I blocked off an hour on my calendar each day to dedicate solely to the CRM
migration. During that time, I worked on transferring the data, as well as cleaning out
old contacts and fixing outdated information. Doing this gave me enough time to chip
away at that project while still handling my normal tasks.”
■ Result: “As a result, the transfer was completed two weeks ahead of deadline and I
finished the quarter 10% ahead of my sales goal. The new CRM has also helped us

88 | Pratham Kohli
get more organised as a team, and overall our department sales are up 25% year over
year.”

Disclaimer: All the questions and LPs below are from the Leetcode post: link
[ Nothing is internal, all this was available before I joined any MAANG company. ]

Following is a short and concise (I know even this is long...) list of potential behavioural
Leadership Principles (LPs). SDEs can avoid the last 3 LPs.

Customer Obsession: Start with the customer and work backwards — leaders obsess over
customers

● A time you used customer feedback to drive improvement


● Most difficult customer interaction
● A time where you had to balance the needs of the customer vs. the business

Insists on Highest Standards: Have relentlessly high standards and continuously raise the
bar/drive others to do the same

● A time you were unsatisfied with the status quo. How would you change it?
● Describe the most significant improvement project you’ve lead
● How do you seek out feedback on performance?

Delivers Results: Focus on key inputs and deliver with high quality in a timely fashion

● A time you were driving toward a goal and realised more than half way in that it may
not be the best goal
● A goal you set that took a long time to achieve/are still working towards
● A time you delivered a project under a tight deadline

Bias for Action: Speed is crucial at Amazon — value calculated risk taking

● A time where you’ve taken a calculated risk where speed was crucial
● A time you made an important decision without consulting your manager
● A time where you were able to remove serious roadblocks preventing progress

Invent and Simplify: Expect and require innovation from yourself and those around you —
always find ways to simplify

● The most innovative thing you’ve done and why you think it’s innovative
● A time where you solved a complex problem with a simple solution
● A creative idea you had that ended up being difficult to implement

Complete Switching Bootcamp | 89


Ownership: Think long term and don’t sacrifice value for short-term results — there is no
such thing as “not my job”

● A time you took on something significant outside your responsibility


● A time you made a decision to sacrifice short term gain for a longer term goal
● A time you saw a peer struggling and decided to step in and help

Dive Deep: Stay connected to details, audit frequently, and question when metrics differ

● A time you were trying to understand a problem on your team and had to go down
several layers to figure it out
● A time you linked two or more problems together an identified an underlying issue
● A specific metric you have used to identify a need for a change in your department

Learn and be Curious: Always seeking improvement — curious about new possibilities

● A time you realised you needed to have a deeper level of subject matter expertise to
do your job well and love to explore them
● A time you took on work outside of your comfort area and found it rewarding
● A time you didn’t know what to do next or how to solve a challenging problem

Disagree and Commit: Obligation to respectfully challenge decisions when you disagree,
then fully committing

● A time you strongly disagreed with your manager


● A time you took an unpopular stance in a meeting with peers/leaders and convinced
them on your side
● A time you decided to go along with the group decision even if you disagreed
● A time when you disagreed, spoke your thoughts, but then agreed to commit even if it
wasn’t the way you wanted to go

Earn Trust: Listen attentively, speak candidly, and treat others respectfully

● A time you significantly contributed to improving morale and productivity on your


team
● 3 things you’re working on to improve overall effectiveness
● A time you received tough or critical feedback

Think Big: Thinking small is a self- fulfilling prophecy. Leaders create and communicate a
bold directions that inspires results

● A time of a radical approach you proposed to solve a big problem


● A time when you took a big risk and it failed

Hire & Develop The Best: Raise the performance bar with every hire & promotion.
Recognize talent, and willingness to move them throughout the organisation

● How you help your team members develop their careers

90 | Pratham Kohli
● A time when you provided feedback to develop & leverage the strengths of someone
on your team.

Frugality: A time when you thought about saving a cost for your team

● A time when you implemented a mechanism that saved money for your business
● A time when you spotted something in the business was wasting money

Are Right A Lot: Strong judgement and good instincts

● A time you made a difficult decision and how you knew it was the right decision.
● A time you made a decision without data
● A time you made a bad decision and how you learned from it

Complete Switching Bootcamp | 91


Phase 8 - Acing Interviews

How to Prepare for Interviews ?

1. Giving Mock Interviews is definitely recommended.


From where to give Mocks ?
- You can find people on Linkedin offering free and paid mocks
- We have this site called pramp.com [ link ] for free Mocks
- You can sync up with your friends and can take each other’s mock interview

2. Another strategy is:


- For any question be it DSA, LLD, HLD, start a timer and time yourself while you solve the
question. It sets up a real Interview Environment.
- Now tackle the problem and speak as you would in a real interview with a real Interviewer
- Record yourself while you do this
- Later analyse everything:
- What you said,
- What could have been better
- Where did you get stuck
- What things to avoid
- Keep this very professional and make sure you use English at all times

3. One more strategy is to go ahead with real life interviews at real companies
- Start applying to companies you know you are not going to join
- Nothing beats the thrill of a real time interview
- Helps you assess where you are in your prep journey and gives you the required practice
and points to improve on

Basics for the Interview


1. Dress well. Look sharp. Whatever anybody says, 1st impressions always matter. Make a
good one.

2. Have a good introduction ready.

3. Have a smile on your face.

4. Join the interviews 5 mins early.

92 | Pratham Kohli
General Guidelines for All Interviews:
1. Have a good sleep the night before, it helps I am telling you with experience.
2. Join the meeting 5 mins prior always, so that you become familiar with the
environment you are in. It helps keep you calm
3. Always have your charger connected to the laptop and close to a power source, just in
case the battery runs out or becomes low, plug it in.
4. Keep your phone close to you to use hotspot in case your Wifi betrays you in the
interview.
5. Before starting the interview, provide your number in the Zoom chat, in case you
think the internet may go down or the call may disconnect for any reason.
6. Breathing exercises before the interview helps if you are feeling too stressed or
anxious.
7. Most interviewers want you to succeed.
8. Go with a winning mindset and be confident of your abilities.
9. Keep a crisp introduction ready as most interviewers tend to ask you to introduce
yourself.
10. Always start the conversation with a Smile ( seems basic but everybody likes a
cheerful person, don’t you like it when a stranger smiles at you ? [Not in the weird
way though :p ] )
11. Understanding the problem well is the first step during interviews.
12. Never jump straight to the solution.
13. Record any unique information present in the problem. ( write it down on the screen
which is mutually shared)
14. Write down 2-3 test cases to understand the input/output.
15. Never assume things which are not given in the problem.
16. Whatever problem you get, start from basic principles, always tell the brute force
approach first to the interviewer. Explain it quickly as that does not take more than 5
mins generally.
17. Then start providing the optimised solution. [ Solution first. Optimizations later. ]
18. Why brute force soln first ?
- In case you can’t think the optimised solution, it gives you a lead to see what code
blocks can be optimised,
- It lets the interviewer know that you know at least one solution, instead of
interviewer thinking that why are you not able to provide even the basic solution to a
basic problem
19. Always keep speaking what you are thinking, it keeps the interviewer involved and
gives them data points into how you think.
20. If stuck, iterate over all Data structures you know: Stack ? Queue ? Heap? Linked List
? Graph ? to see what soln may work.
21. Listen carefully to the interviewer for hints/suggestions.
- The interviewer may have a solution in mind and sometimes they would want you to
implement that solution only. So be all ears on whatever the interviewer says!
22. It’s ok to use pen and paper and take notes during the interview.

Complete Switching Bootcamp | 93


23. Writing and visualising on paper can unlock the creative part of your brain.
24. Ask for hints if stuck for long.
25. Pick a programming language you are most comfortable with.
26. Discuss your approach before you begin coding, not after.
27. Think of multiple solutions before committing to one.
28. State the time and space complexity upfront.
29. Break down complex questions into smaller problems.
30. Always test edge cases ( null input, overflow possibility input)
31. Start coding only when you know exactly what you are going to write.
32. Write clean, readable and modular code.
33. . Reuse code whenever possible.
34. Use good variable names. No i, j, k, tmp.
35. Try to make your solution generic instead of hard-coding.
36. Dry run your solution on 2-3 sample inputs.
37. Your solution is as good as how well you communicate it.
38. Don’t ignore behavioural questions. They are important too. [ I hope you wrote
answers using STAR method in above section ]
39. Prepare a few good questions to ask in the end.
40. Irrespective of the result, reflect on your interview experience.
41. Always Always Always go through interview experiences of the company you
have the interview lined up for, be it OA, or a Normal Interview !!
Why ? Very high chance of questions getting repeated sometimes
Sites for Interview experiences: Leetcode, GeeksForGeeks
42. What about questions that you don’t know ?
a. It is okay to let the interviewer know that you do not know the answer.
b. If you start lying, it is going to hurt you a lot if they ask follow up questions.
c. However, you need to still solve the question, so start with “ I don’t know
about this but Here is what I would do to tackle this problem….”
d. Then try to think of related things and keep speaking your mind out, the
interviewer will nudge you in the right direction or may change the questions
altogether ( rare )
e. As a Software Engineer, this is your job to tackle things you don’t already
know about
f. Now what does this show: We are truthful, and at the same time we Don’t
Give Up. Not giving up is such an important trait to show in interviews if you
are put in such a situation!!

94 | Pratham Kohli
Why should you Ask Questions at the end of An Interview?
- Always ask a question, never ever say no questions
- It matters in some companies, in some it does not
- But it always creates an impression on the interviewer, showing how interested /
uninterested you are in joining them
- You always need to showcase that you are extremely interested in the company even
if you are not

Sample Question To Ask:


- 3 qualities needed to succeed in this team.
- 3 qualities needed to succeed in the Company as per your experience.
- How are KPI ( Key performance metrics ) measured as part of Annular Review ?
- How does the company measure the success of its software engineering projects?
- Biggest Challenge the company is facing at the moment ?
- One thing you love and hate about working at your company ?
- How to stand out in the role the team is hiring for ?
- What are the ideal qualities you are looking for in the candidate you are hiring for, for
this role?
- Most Challenging project you have accomplished till date at the company ?
- What challenges will I face in the first 90 days of onboarding?

Complete Switching Bootcamp | 95


- Naukri : Remain active here and slowly a lot of recruiters start showing interest in
your profile and contacting you.
Pro Tip: Keep changing something or the other in your profile, it depicts that you are
active on the platform. Make sure to login everyday so that your profile is actively
shown to recruiters!
Link to Site

- Instahyre: People get a lot of leads from here as well. Creating a profile is pretty
simple.
Link to Instahyre

- Indeed: This is another platform we can explore but it is not very good at the moment
for India, so I used it only to apply directly to the company Indeed!
Link to Indeed

98 | Pratham Kohli

You might also like