The single most effective shift you can make in your interview preparation is moving from problem memorization to pattern recognition. Top candidates do not remember the solution to every LeetCode problem — they recognize the pattern and derive the solution from first principles.
This is the philosophy behind DSAPatterns.io and its industry-leading 18 DSA patterns cheat sheet. Here is a breakdown of each pattern, when to use it, and the canonical signal that tells you a problem falls into that category.
Why Patterns Beat Problem Grinding
There are over 3,000 problems on LeetCode. No one solves all of them. But the top candidates at Google, Amazon, and Microsoft all share one trait: they have internalized the core algorithmic patterns that underlie those 3,000 problems.
Research and anecdotal evidence from hundreds of FAANG interviewers agree: the ability to quickly identify the pattern a problem belongs to is the most reliable predictor of interview success. Not the number of problems solved.
The 18 DSA Patterns: Quick Reference
1. Two Pointers
Use when: The input is a sorted array or string, and you need to find pairs, triplets, or perform comparisons from both ends. Signal: You need O(n) time on a sorted structure.
2. Sliding Window
Use when: You need the maximum, minimum, or a condition across a contiguous subarray or substring of variable or fixed length. Signal: 'Find the longest/shortest subarray that...'
3. Fast and Slow Pointers
Use when: You are working with a linked list or cycle detection problem. Signal: The problem mentions a cycle, or asks you to find the middle of a list.
4. Merge Intervals
Use when: You are given a list of intervals and asked to merge, insert, or find overlaps. Signal: Input contains pairs of [start, end] values.
5. Cyclic Sort
Use when: The input is an array of numbers in a range 1 to n. Signal: 'Find the missing number' or 'Find the duplicate' in a bounded range.
6. In-place Linked List Reversal
Use when: You need to reverse a linked list or a sub-portion of it. Signal: The problem asks you to reverse without extra space.
7. BFS (Breadth-First Search)
Use when: You need to find the shortest path in an unweighted graph or traverse level by level. Signal: 'Minimum steps,' 'level order traversal,' or 'nearest neighbor.'
8. DFS (Depth-First Search)
Use when: You need to explore all paths, backtrack, or traverse a tree/graph exhaustively. Signal: 'All possible paths,' 'permutations,' or 'combinations.'
9. Two Heaps
Use when: You need to find the median of a data stream, or track the largest/smallest element dynamically. Signal: The problem asks for a running median or 'kth largest at each step.'
10. Subsets / Combinations
Use when: You need to generate all subsets, permutations, or combinations. Signal: 'Return all possible...' or 'find all subsets that...'
11. Modified Binary Search
Use when: The input is sorted (or partially sorted) and you need to search efficiently. Signal: Sorted input + a search condition.
12. Bitwise XOR
Use when: The problem involves finding a unique element or pairs that cancel out. Signal: 'Every element appears twice except one.'
13. Top K Elements
Use when: You need to find the K largest, smallest, or most frequent elements. Signal: 'Top K,' 'K closest,' or 'K most frequent.'
14. K-way Merge
Use when: You need to merge K sorted arrays, lists, or streams. Signal: Multiple sorted inputs that need to be combined.
15. Dynamic Programming
Use when: The problem has overlapping subproblems and optimal substructure. Signal: 'Maximum profit,' 'minimum cost,' 'number of ways,' or 'is it possible to...'
16. Topological Sort
Use when: You have tasks with dependencies and need to find a valid ordering. Signal: Directed acyclic graph (DAG) + dependency relationships.
17. Trie
Use when: The problem involves prefix matching, word search, or autocomplete. Signal: String problems involving shared prefixes.
18. Union Find
Use when: You need to group elements into disjoint sets or detect cycles in an undirected graph. Signal: 'Number of connected components' or 'are these nodes connected?'
How to Use This Cheat Sheet Effectively
The goal is not to memorize this list. The goal is to internalize the signals — the keywords and structural clues in a problem statement that tell you which pattern applies. Practice this identification skill on every problem you solve.
DSAPatterns.io accelerates this process with Socratic hints that train your pattern recognition instinct on real company-tagged problems. The platform is built around this exact cheat sheet.
Conclusion
The 18 DSA patterns cheat sheet is the most efficient frame for coding interview preparation available today. Combined with targeted practice on DSAPatterns.io, it gives you the tools to approach any new problem with confidence — not just the ones you have seen before.
Start practicing with the full interactive pattern database at https://dsapatterns.io/