Pattern-Based DSA Mastery

Stop watching 500 videos. Learn the patterns.

Every coding interview problem stems from fundamental algorithmic patterns. Master the core intuition, walkthrough, and C++ template for each category.

0
Problems
0%
Completed
0/12
Mastered
Overall Progress:0 / 234 Solved

Roadmap Topics

(12 of 12)
011-2 weeks
0/20 Solved

Arrays and Strings

Learn in-place updates and prefix sums first; nearly every later topic builds on them. Start with a quick read on Big-O (the idea only), then begin.

Traversal and running valueWrite pointer (in-place edit)Prefix and suffix arrays+5 more
021 week
0/17 Solved

Hashing

Hashing turns a nested-loop O(n^2) search into one O(n) pass by remembering what you have seen. In C++ that means unordered_map and unordered_set.

Complement lookupFrequency countCanonical key grouping+4 more
031-2 weeks
0/16 Solved

Two Pointers and Sliding Window

Both patterns replace a nested loop with two indices that only move forward, giving O(n). Two pointers needs sorted or symmetric structure; a sliding window needs a contiguous range.

Opposite endsFix one, two-pointer the restFast and slow / write pointer+5 more
041-2 weeks
0/18 Solved

Stack and Queue

Use a stack when the most recent unfinished thing matters, and a queue when order of arrival matters. The monotonic stack is the pattern that shows up most often. In C++: stack, queue, deque.

Matching and nestingExpression evaluationMonotonic stack (next greater or smaller)+4 more
051-2 weeks
0/20 Solved

Linked List

Linked list problems are about careful pointer handling, and four tools cover most of them: a dummy node, fast and slow pointers, in-place reversal, and merging. Draw the pointers on paper before coding.

Dummy head nodeFast and slow pointersIn-place reversal+5 more
061-2 weeks
0/18 Solved

Binary Search

Binary search works on any yes/no condition that flips once across an ordered range, not just on sorted arrays. Decide what lo and hi mean before you write code. In C++, know lower_bound and upper_bound, and compute mid as lo + (hi - lo) / 2.

Classic searchLower and upper boundRotated sorted array+4 more
071-2 weeks
0/19 Solved

Recursion and Backtracking

Backtracking is recursion that builds a candidate one choice at a time, undoes the choice, and tries the next. Every problem fits one template: choose, recurse, un-choose. Draw the decision tree for a tiny input before coding.

Include or excludePermutationsCombinations with a start index+4 more
082 weeks
0/23 Solved

Trees and BST

A tree problem is almost always one recursive function; decide what each node returns to its parent and what it reports on the side. Do the easy depth and traversal problems until recursion feels natural, then move to BST rules and path problems.

DFS traversalsBottom-up return valueReturn one thing, update another+6 more
091 week
0/18 Solved

Heap and Priority Queue

Reach for a heap whenever you repeatedly need the smallest or largest item from a changing collection. In C++, priority_queue<int> is a max-heap by default; use greater<int> for a min-heap, or a custom comparator for pairs and structs.

Top K with a size-K min-heapKth element in a streamFrequency + heap+4 more
101-2 weeks
0/18 Solved

Greedy and Intervals

A greedy solution makes the locally best choice at each step and never revisits it; most interval problems become greedy once you sort. The skill is justifying the choice, so for each problem ask why the local pick cannot hurt the final answer.

Sort, then sweepMerge intervalsInterval scheduling+5 more
112-3 weeks
0/23 Solved

Graphs

Most graph problems reduce to a handful of traversals; the real work is spotting the graph, such as a grid, a course list or a set of equations. In C++, store the graph as vector<vector<int>> adjacency lists and keep a visited array.

DFS on componentsGrid as a graphBFS for shortest path (unweighted)+7 more
123-4 weeks
0/24 Solved

Dynamic Programming

DP is recursion that remembers its answers; do not try to see the table first. For every problem work in four steps: define the state in words, write the recursion, add memoization, then convert to a table and shrink the space if possible.

1D linear0/1 knapsackUnbounded knapsack+7 more