Lesson 5 � Expert
Capstone: Complete DSA Revision
Congratulations! Tumne 10 modules complete kar liye. Ab sabka quick revision karte hain � cheat sheet, time complexity table, aur top problems per module. Interview se pehle ye sabse useful hoga!
Complete DSA Roadmap
MODULE 01: Arrays & Strings
✓ Arrays, Two Pointers, Sliding Window, Prefix Sum, Array Problems
MODULE 02: Linked Lists
✓ LL Basics, Operations, Problems
MODULE 03: Stacks & Queues
✓ Stack Basics, Queue Basics, Valid Parentheses, Next Greater Element
MODULE 04: Sorting Algorithms
✓ Bubble, Selection, Insertion, Merge, Quick Sort
MODULE 05: Recursion & Backtracking
✓ Recursion Basics, Patterns, Backtracking, N-Queens
MODULE 06: Trees
✓ Tree Basics, Height, Construction, Path, BST
MODULE 07: Heaps & Priority Queues
✓ Heap operations, Top K elements, Median stream
MODULE 08: Graphs
✓ Graph Basics, BFS/DFS, Dijkstra, MST, Cycle Detection, Topological Sort
MODULE 09: Binary Search
✓ BS Basics, Lower/Upper Bound, Rotated Array, BS on Answer, Problems
MODULE 10: Tries & Advanced
✓ Trie, Segment Tree, Bit Manipulation, Interview Patterns, Capstone
Time Complexity Cheat Sheet
+-----------------------------------------------------+
� Operation � Time � Space �
�---------------------------+----------+--------------�
� Array Access � O(1) � O(1) �
� Array Search (unsorted) � O(n) � O(1) �
� Array Search (sorted) � O(logn) � O(1) �
� Array Insert/Delete (end) � O(1) � O(1) �
� Array Insert/Delete (mid) � O(n) � O(n) �
�---------------------------+----------+--------------�
� Linked List Access � O(n) � O(1) �
� Linked List Insert (head) � O(1) � O(1) �
� Linked List Search � O(n) � O(1) �
�---------------------------+----------+--------------�
� Stack Push/Pop � O(1) � O(n) �
� Queue Enqueue/Dequeue � O(1) � O(n) �
�---------------------------+----------+--------------�
� Merge Sort � O(nlogn)� O(n) �
� Quick Sort (avg) � O(nlogn)� O(logn) �
� Quick Sort (worst) � O(n�) � O(n) �
�---------------------------+----------+--------------�
� BST Search/Insert � O(h) � O(h) �
� BST (balanced) � O(logn) � O(logn) �
�---------------------------+----------+--------------�
� Heap Insert/Extract � O(logn) � O(n) �
� Heap Find Min/Max � O(1) � O(1) �
�---------------------------+----------+--------------�
� BFS/DFS (adj list) � O(V+E) � O(V) �
� Dijkstra � O(ElogV)� O(V) �
�---------------------------+----------+--------------�
� Binary Search � O(logn) � O(1) �
� Trie Insert/Search � O(L) � O(ALPHABET�L�N)�
� Segment Tree Build � O(n) � O(4n) �
� Segment Tree Query/Update � O(logn) � O(1) �
+-----------------------------------------------------+
Top 5 Problems Per Module
Module 1: Arrays
1. Two Sum
2. Best Time to Buy/Sell Stock
3. Contains Duplicate
4. Product of Array Except Self
5. Maximum Subarray (Kadane's)
Module 2: Linked Lists
1. Reverse a Linked List
2. Merge Two Sorted Lists
3. Linked List Cycle
4. Remove Nth Node From End
5. Reorder List
Module 3: Stacks & Queues
1. Valid Parentheses
2. Min Stack
3. Next Greater Element
4. Daily Temperatures
5. Implement Queue using Stacks
Module 4: Sorting
1. Merge Sort implementation
2. Quick Sort implementation
3. Sort Colors (Dutch National Flag)
4. Kth Largest Element
5. Meeting Rooms II
Module 5: Recursion
1. Subsets
2. Permutations
3. N-Queens
4. Sudoku Solver
5. Word Search
Module 6: Trees
1. Maximum Depth
2. Same Tree / Invert Tree
3. Binary Tree Level Order
4. Validate BST
5. Lowest Common Ancestor
Module 7: Heaps
1. Kth Largest Element
2. Top K Frequent Elements
3. Find Median from Data Stream
4. Merge K Sorted Lists
5. Sliding Window Maximum
Module 8: Graphs
1. Number of Islands
2. Clone Graph
3. Course Schedule (Topological Sort)
4. Network Delay Time (Dijkstra)
5. Redundant Connection (Union-Find)
Module 9: Binary Search
1. Binary Search
2. Search in Rotated Array
3. Koko Eating Bananas
4. Median of Two Sorted Arrays
5. Capacity to Ship Packages
Module 10: Advanced
1. Implement Trie
2. Word Search II
3. Range Sum Query (Segment Tree)
4. Single Number (Bit Manipulation)
5. Subset Generation (Bitmask)
Quick Code Implementations
# Binary Search Template
def bs(arr, target):
lo, hi = 0, len(arr) - 1
while lo <= hi:
mid = (lo + hi) // 2
if arr[mid] == target: return mid
elif arr[mid] < target: lo = mid + 1
else: hi = mid - 1
return -1
# BFS Template
from collections import deque
def bfs(graph, start):
q = deque([start])
visited = {start}
while q:
node = q.popleft()
for nb in graph[node]:
if nb not in visited:
visited.add(nb)
q.append(nb)
# Union-Find Template
class UF:
def __init__(self, n):
self.p = list(range(n))
def find(self, x):
if self.p[x] != x: self.p[x] = self.find(self.p[x])
return self.p[x]
def union(self, a, b):
pa, pb = self.find(a), self.find(b)
if pa != pb: self.p[pa] = pb; return True
return False
# Trie Template
class TrieNode:
def __init__(self):
self.ch = {}; self.end = False
Try it: Mixed Problem Set
Final Exercise
Question: Array [1, -2, 3, 4, -1, 2, 1, -5, 4] ka maximum subarray sum kya hai? (Kadane's Algorithm) Answer mein number daalo.
Question: Sorted array [1, 2, 3, 4, 5, 6, 7] mein value 4 ka index kya hai✓ Binary Search use karo. Answer mein index number daalo.
Interview Tips
- 2 minute rule: Problem padho, 2 minute socho, phir approach discuss karo. Seedha code mat likho.
- Clarify karo: Edge cases pucho � empty input✓ Single element✓ Negative numbers?
- Brute force pehle: Pehle brute force approach batao, phir optimize karo. Interviewer ko dikhega tumhara thinking process.
- Think aloud: Apne thoughts bolo � interviewer ko pata chalega tum kya soch rahe ho.
- Test karo: Code likhne ke baad dry run karo � 2-3 test cases se verify karo.
- Complexity batao: Har solution ke baad time aur space complexity bolo.
Tumne 10 modules, 50 lessons, aur 100+ problems cover kar liye. Ab practice karo � LeetCode pe daily 2 problems solve karo. All the best for your interviews!