A pattern-first DSA practice roadmap. Each section groups problems by the idea you should learn, not just by difficulty, so you can recognize the same technique when it appears in a new form.
Important: Do not solve random problems. Solve problems pattern by pattern, understand why that pattern works, and remember the trigger for using it. The goal is to recognize the pattern in a new question, not to memorize one exact solution.
Start with one topic folder, read its README.md, then solve the problems in order. Each topic README has one-click links in the last column so you can open any question directly.
| No. | Topic | Problems | Start Here |
|---|---|---|---|
| 1 | π¦ Arrays | 57 | Open |
| 2 | πͺ Sliding Window + Prefix Sum | 49 | Open |
| 3 | π€ Strings + Hashing | 60 | Open |
| 4 | π Linked List | 50 | Open |
| 5 | π Stack + Queue | 49 | Open |
| 6 | π― Binary Search | 50 | Open |
| 7 | π³ Trees + BST | 42 | Open |
| 8 | β°οΈ Heap + Greedy | 20 | Open |
| 9 | π§© Backtracking | 20 | Open |
| 10 | πΈοΈ Graphs | 20 | Open |
| 11 | π§ Dynamic Programming | 10 | Open |
π Current question files: 427
Do not jump to code first. Spend a few minutes identifying the shape of the problem.
-
Restate the task Say what the input is, what output is needed, and what counts as a valid answer.
-
Check constraints Constraints tell you the allowed time complexity. If
nis huge, avoid nested loops. If the input is sorted, think binary search or two pointers. -
Find the pattern Ask what the problem is really about: searching, counting, grouping, shortest path, choosing best value, recursion, or state transition.
-
Try a brute force idea Write the simplest possible logic mentally. Then ask which part repeats too much.
-
Optimize the repeated work Use a hashmap, prefix sum, sliding window, stack, heap, binary search, DFS/BFS, or DP depending on what is being repeated.
-
Dry run Test your idea on a small example and one edge case before writing code.
-
Code cleanly Keep variables meaningful. Handle empty input, single element input, duplicates, and boundary indexes.
-
Analyze Always finish with time and space complexity.
Use these signals to choose a technique quickly.
| Signal in Problem | First Technique to Try |
|---|---|
| π Sorted array, find pair/range | Two pointers or binary search |
| πͺ Subarray or substring with condition | Sliding window |
| β Sum/count over many ranges | Prefix sum |
| π Need fast lookup or frequency | HashMap / HashSet |
| π Next greater/smaller, remove while condition holds | Monotonic stack |
| β°οΈ Top K, smallest/largest repeatedly | Heap |
| π― Minimum/maximum answer with yes/no check | Binary search on answer |
| π§© All combinations or permutations | Backtracking |
| πΊοΈ Grid, connected components, shortest unweighted path | BFS / DFS |
| π Dependencies or ordering | Topological sort |
| π§ Repeated choices with optimal result | Dynamic programming |
| π Linked list cycle or middle | Slow and fast pointers |
| π Intervals overlap or merging | Sort by start/end, then greedy |
Think about index movement. If the array is sorted, use two pointers or binary search. If you need repeated range values, use prefix or suffix arrays.
Use when the answer is a continuous subarray or substring. Expand the right pointer, shrink the left pointer when the condition breaks, and update the answer at the right moment.
Convert string problems into counts, indexes, or character states. Hash maps help with anagrams, frequency, first occurrence, and duplicate detection.
Draw pointer movement before coding. For cycle, middle, or nth-from-end questions, slow-fast pointers are usually the cleanest start.
Use stack when the latest item must be resolved first. Use monotonic stack when elements wait for a future greater/smaller value. Use queue/BFS when processing level by level.
Binary search is not only for arrays. If the answer is numeric and you can check whether a value is possible, binary search the answer.
Most tree problems are DFS with information passed down or returned up. For BSTs, use the sorted property to prune unnecessary branches.
Use heap when you repeatedly need the smallest or largest item. Use greedy when a local best choice can be proven to keep the future valid.
Think in choices: choose, explore, undo. Add pruning rules early so you do not explore impossible paths.
Model nodes and edges first. Use BFS for shortest path in unweighted graphs, DFS for components, Union-Find for connectivity, and topological sort for dependencies.
Use DP when the same subproblem appears again and choices affect future results. Define the state, transition, base case, and answer location.
The goal is not to memorize exact solutions. Remember the pattern trigger and the key trick.
- After solving, write one sentence: "This problem is solved by ___ because ___."
- Re-solve the same problem after 1 day, 3 days, and 7 days.
- Group mistakes by type: wrong pattern, missed edge case, bad index handling, or weak implementation.
- Keep a small list of "signature problems" for each pattern.
- Before looking at a solution, spend at least 15 minutes forming a brute force and optimized idea.
- After reading a solution, close it and code again from memory.
- Compare similar problems together so the pattern becomes visible.
When stuck:
- First 5 minutes: understand examples and constraints.
- Next 5 minutes: write brute force logic.
- Next 5 minutes: identify repeated work and choose a pattern.
If you still cannot solve it, read only the hint or approach, then code the solution yourself.
Use this cycle for strong retention:
| Day | Work |
|---|---|
| π’ Day 1 | Solve 5 new problems from one pattern |
| π΅ Day 2 | Revise yesterday's problems and solve 3 new ones |
| π‘ Day 4 | Re-solve the problems you got wrong |
| π£ Day 7 | Mix problems from 2-3 older patterns |
| π Day 14 | Do timed practice without hints |
| π΄ Day 30 | Revisit only weak patterns |
Use this checklist before submitting:
1. What is the input and output?
2. What are the constraints?
3. Is the data sorted, repeated, connected, or continuous?
4. What brute force solution works?
5. What work is repeated?
6. Which pattern removes that repeated work?
7. What are the edge cases?
8. What is the time and space complexity?
- π¦ Arrays
- πͺ Sliding Window + Prefix Sum
- π€ Strings + Hashing
- π Linked List
- π Stack + Queue
- π― Binary Search
- π³ Trees + BST
- β°οΈ Heap + Greedy
- π§© Backtracking
- πΈοΈ Graphs
- π§ Dynamic Programming
Follow the order if you are building fundamentals. If you are preparing for interviews soon, rotate between one easy, two medium, and one revision problem daily.