DSA Interview Patterns
5 min read Quiz at the end
Ten DSA interview patterns — sliding window, two pointers, BFS/DFS, DP, heap, trie, union-find.
DSA Interview Patterns
| Pattern | Problems | Key Data Structure |
|---|
| Sliding Window | Max subarray, Longest substring no repeat | Array, HashSet |
| Two Pointers | Two Sum sorted, 3Sum, Remove duplicates | Sorted Array |
| Binary Search | Search rotated array, Min in rotated, K closest | Sorted Array |
| BFS | Shortest path, Level order, Islands | Queue |
| DFS/Backtracking | Permutations, Subsets, N-Queens | Stack/Recursion |
| Dynamic Programming | LCS, Knapsack, Coin change, LIS | Array/HashMap |
| Heap / Priority Queue | Top K, Merge K lists, K closest | Min/Max Heap |
| Trie | Autocomplete, Word search II | Trie |
| Union-Find | Connected components, Redundant connection | DSU |
| Monotonic Stack | Next greater element, Daily temperatures | Stack |
# Problem-solving framework
# 1. Clarify: edge cases, constraints, input size
# 2. Brute force: state the naive O(n^2) approach
# 3. Optimise: sliding window / hash / sort / DP
# 4. Code: clean, handle edge cases
# 5. Test: [], [x], large n, duplicates, negatives
Topic Quiz · 1 questions
Test your understanding before moving on
1. Which data structure is used to implement BFS efficiently?
💡 BFS uses a queue (FIFO) — nodes are explored level by level in the order they are discovered.