Fundamental Questions¶
1. Arrays and Strings¶
Key Concepts: Sliding window, two pointers, prefix sum, Kadane’s algorithm, string manipulation.
Problems to Practice:
Longest substring without repeating characters
Maximum subarray sum (Kadane’s algorithm)
Rotate array (in-place rotation)
Valid palindrome
String pattern matching (e.g., KMP algorithm, Rabin-Karp)
2. Hashing¶
Key Concepts: Hash maps, sets, frequency counts, collision handling.
Problems to Practice:
Two-sum problem variants.
Longest substring with at most k distinct characters.
Group anagrams.
Subarray with a given sum (hash map for prefix sums).
3. Linked Lists¶
Key Concepts: Fast and slow pointers, reversing, merging, detecting cycles.
Problems to Practice:
Reverse a linked list.
Merge two sorted linked lists.
Detect and remove cycle in a linked list.
Intersection of two linked lists.
Flatten a multilevel doubly linked list.
4. Trees and Graphs¶
Key Concepts:
Trees: Traversals (DFS, BFS), recursion, binary search tree properties.
Graphs: Representations (adjacency list/matrix), DFS, BFS, Dijkstra, union-find.
Problems to Practice:
Binary tree level order traversal.
Lowest common ancestor (LCA).
Validate binary search tree.
Number of islands (DFS/BFS).
Shortest path in a graph (Dijkstra’s algorithm).
Detect cycle in an undirected graph (union-find).
5. Recursion and Backtracking¶
Key Concepts: Base case, recursive stack, pruning.
Problems to Practice:
Permutations and combinations.
N-Queens problem.
Sudoku solver.
Subset sum problem.
Word search in a grid.
6. Dynamic Programming¶
Key Concepts: Memoization, tabulation, state definition, transitions.
Problems to Practice:
Longest increasing subsequence.
Longest common subsequence.
0/1 Knapsack problem.
Coin change problem.
Edit distance (Levenshtein distance).
7. Sorting and Searching¶
Key Concepts: Merge sort, quicksort, binary search (with variations).
Problems to Practice:
Search in a rotated sorted array.
Median of two sorted arrays.
Kth largest element in an array.
Closest pair of points.
8. Stacks and Queues¶
Key Concepts: Monotonic stack, deque (double-ended queue), LRU cache.
Problems to Practice:
Valid parentheses.
Largest rectangle in histogram.
Sliding window maximum.
Implement a queue using two stacks.
9. Bit Manipulation¶
Key Concepts: XOR, bit shifts, masking, counting set bits.
Problems to Practice:
Single number (XOR-based solution).
Subsets using bit masks.
Reverse bits.
Count the number of 1 bits (Hamming weight).
10. Math and Geometry¶
Key Concepts: GCD, LCM, modular arithmetic, Euclidean algorithm.
Problems to Practice:
Check if a number is prime.
Find GCD/LCM of two numbers.
Count primes up to n (Sieve of Eratosthenes).
Water trapped after rainfall (two-pointer approach).