DSA Cheat Sheet for 40 LPA Roles
Want a 40 LPA Role? Get My Free DSA Cheat Sheet
Created by minhazcoding
Telegram: t.me/minhazcoding Instagram: minhazcoding
Introduction
Mastering Data Structures and Algorithms (DSA) is essential for securing high-paying tech roles at
companies like Google, Amazon, and Microsoft. This comprehensive cheat sheet provides detailed
guidance on key DSA topics, including 10 practice questions per topic to help you prepare for coding
interviews. With consistent practice, you can land a 40 LPA (Lakhs Per Annum) role. Lets dive into
the core topics and questions!
1 Arrays and Strings 1.3 Tips for Success
Arrays and strings are foundational data struc- • Practice time complexity optimization (aim
tures frequently tested in coding interviews. They for O(n) or better).
require efficient manipulation techniques like two- • Use online platforms like LeetCode.
pointers and sliding windows.
• Visualize array operations to avoid off-by-
1.1 Key Concepts one errors.
▷ Array traversal and manipulation
2 Linked Lists
▷ Two-pointer technique
Linked lists test your understanding of pointers
▷ Sliding window approach
and dynamic memory. They are common in in-
▷ String parsing and substring operations terviews due to their recursive nature.
1.2 Top 10 Practice Questions 2.1 Key Concepts
1. Reverse an array in-place without using ex- ▷ Singly and doubly linked lists
tra space.
▷ Cycle detection (Floyds algorithm)
2. Find the maximum subarray sum (Kadanes
Algorithm). ▷ Reversing a linked list
3. Check if a string is a palindrome. ▷ Merging and splitting lists
4. Find the longest substring without repeat-
ing characters. 2.2 Top 10 Practice Questions
5. Merge two sorted arrays into one sorted ar- 1. Reverse a singly linked list.
ray. 2. Detect a cycle in a linked list.
6. Rotate an array by k steps. 3. Merge two sorted linked lists.
7. Find the first non-repeating character in a 4. Remove the nth node from the end of a
string. linked list.
8. Implement a function to check if two strings 5. Find the intersection point of two linked
are anagrams. lists.
9. Find the missing number in an array of 1 to
6. Check if a linked list is a palindrome.
n.
7. Rotate a linked list by k nodes.
10. Group anagrams together from a list of
strings. 8. Add two numbers represented as linked lists.
1
DSA Cheat Sheet for 40 LPA Roles
9. Remove duplicates from a sorted linked list. 3.3 Tips for Success
10. Implement a function to swap nodes in • Practice recursive and iterative traversal
pairs. methods.
• Use adjacency lists for sparse graphs to save
2.3 Tips for Success space.
• Master pointer manipulation to avoid null • Visualize tree structures to simplify
pointer errors. problem-solving.
• Use slow and fast pointers for cycle detec-
tion. 4 Dynamic Programming
• Practice recursive solutions for complex
Dynamic Programming (DP) is used for optimiza-
problems.
tion problems with overlapping subproblems and
optimal substructure.
3 Trees and Graphs
4.1 Key Concepts
Trees and graphs are critical for problems involv-
ing hierarchies and networks. They require strong ▷ Memoization vs. tabulation
traversal and search skills. ▷ Breaking problems into subproblems
▷ Common patterns (e.g., knapsack, longest
3.1 Key Concepts common subsequence)
▷ Binary trees and binary search trees
4.2 Top 10 Practice Questions
▷ Depth-First Search (DFS) and Breadth-
First Search (BFS) 1. Solve the 0/1 knapsack problem.
▷ Graph representation (adjacency list/matrix) 2. Find the longest common subsequence of
two strings.
▷ Shortest path algorithms (Dijkstra, BFS)
3. Compute the minimum path sum in a grid.
3.2 Top 10 Practice Questions 4. Find the number of ways to climb n stairs.
1. Perform an inorder traversal of a binary 5. Solve the coin change problem (minimum
tree. coins needed).
2. Check if a binary tree is a binary search tree. 6. Find the longest palindromic substring.
3. Find the lowest common ancestor in a bi- 7. Implement the edit distance algorithm.
nary tree. 8. Solve the rod-cutting problem.
4. Implement level-order traversal using BFS. 9. Find the maximum product subarray.
5. Find the shortest path in an unweighted 10. Compute the number of unique paths in a
graph. grid with obstacles.
6. Detect a cycle in a directed graph.
4.3 Tips for Success
7. Find the diameter of a binary tree.
• Identify overlapping subproblems early.
8. Serialize and deserialize a binary tree.
• Use 1D or 2D arrays for tabulation to save
9. Implement a function to find all paths from space.
root to leaf.
• Practice both top-down and bottom-up ap-
10. Check if a graph is bipartite. proaches.
2
DSA Cheat Sheet for 40 LPA Roles
5 6-Week Study Plan for DSA Mastery
To land a 40 LPA role, follow this structured 6-week plan to build your DSA skills systematically.
5.1 Week 1-2: Arrays and Strings
• Solve all 10 array and string questions listed above.
• Complete 20 additional easy and 10 medium problems on LeetCode.
• Focus on time and space complexity optimization.
5.2 Week 3-4: Linked Lists and Trees
• Solve all 10 linked list and 10 tree questions.
• Complete 15 medium and 5 hard problems on HackerRank.
• Practice recursive and iterative solutions.
5.3 Week 5-6: Graphs and Dynamic Programming
• Solve all 10 graph and 10 DP questions.
• Complete 10 medium and 10 hard problems on GeeksforGeeks.
• Focus on identifying DP patterns and graph traversal techniques.
5.4 Daily Routine
• Dedicate 2 hours daily to coding practice.
• Review solutions and optimize code for efficiency.
• Participate in mock interviews on platforms like Pramp.
6 Resources to Accelerate Your Learning
• Books:
– "Introduction to Algorithms" by Cormen et al.
– "Cracking the Coding Interview" by Gayle Laakmann McDowell.
• Online Platforms:
– LeetCode for practice problems.
– HackerRank for timed challenges.
– GeeksforGeeks for tutorials.
• Communities: Join Discord or Reddit groups for DSA discussions.
7 Sample Code Snippets
Below are sample solutions for common problems to get you started.
3
DSA Cheat Sheet for 40 LPA Roles
7.1 Reverse an Array
def reverseArray(arr):
left, right = 0, len(arr) - 1
while left < right:
arr[left], arr[right] = arr[right], arr[left]
left += 1
right -= 1
return arr
7.2 Merge Two Sorted Lists
class ListNode:
def __init__(self, val=0, next=None):
self.val = val
self.next = next
def mergeTwoLists(l1, l2):
dummy = ListNode(0)
current = dummy
while l1 and l2:
if l1.val <= l2.val:
current.next = l1
l1 = l1.next
else:
current.next = l2
l2 = l2.next
current = current.next
current.next = l1 if l1 else l2
return dummy.next
8 Mock Interview Tips
• Practice explaining your thought process out loud.
• Solve problems under timed conditions (45 minutes per problem).
• Review your solutions and optimize for edge cases.
• Use platforms like Pramp for mock interviews.
9 Get the Full Cheat Sheet
Download the complete DSA cheat sheet with detailed solutions, additional questions, and advanced
topics at example.com/dsa-cheat-sheet.
Your 40 LPA Journey Starts Now!
Consistency is key. Dedicate time daily, practice diligently, and stay confident. Your dream tech role
is within reach!