DSA
150
1-3 months
Pattern Wise 150
150 essential interview problems grouped by the pattern that cracks them, easy to hard.
150Problems
45Groups
24Easy
102Medium
24Hard
0%0 / 150
01Array Manipulation
5
Instinct "In place", "O(1) extra space" or "one pass" over an array? Think write pointer, reversal, prefix/suffix passes or using indices as storage.Memory hack Read fast, write slow, reverse to rotate, and let the index be the hash.Open the Array Manipulation guide →
02String Manipulation
3
Instinct Reading, comparing or rebuilding text character by character? Walk indices on a char[] and build output with a StringBuilder, never with + in a loop.Memory hack Chars in an array, pointers on the ends, builder at the back - strings are just arrays wearing a costume.Open the String Manipulation guide →
03Hashing & Counting
5
Instinct Need "have I seen this before?", "how many times?" or "group things that look alike"? Trade memory for O(1) lookups with a HashMap, HashSet or int[26].Memory hack Don't search, remember - every element checks in at the front desk, and the desk answers instantly.Open the Hashing & Counting guide →
04Two Pointers
4
Instinct Sorted input, a pair/triple hitting a target, or something symmetric? Put one pointer at each end and move the one that can only improve things.Memory hack Squeeze from both ends - every step throws away a whole row of the brute-force grid.Open the Two Pointers guide →
05Sliding Window
4
Instinct Longest, shortest or count of contiguous subarrays/substrings meeting a rule? Grow a window on the right, shrink it on the left, never step back.Memory hack Move like a caterpillar - the head stretches forward to grab, the tail pulls up only when the body breaks the rule.Open the Sliding Window guide →
06Prefix Sum
3
Instinct Repeated range-sum queries, or "count subarrays whose sum equals / divides K" with negatives allowed? Store running totals and subtract two of them.Memory hack Any range is two prefixes apart - sum(i..j) = P[j+1] - P[i], so remember every P you've passed.Open the Prefix Sum guide →
07Kadane's Running Best
2
Instinct Best sum or product of a contiguous subarray in one pass? At each index choose - extend the run ending here or restart - and track the global best.Memory hack Carry the bag only while it helps - a negative past is dead weight, drop it and restart here.Open the Kadane's Running Best guide →
08Matrix Traversal
3
Instinct A 2D grid you must walk in a fixed geometric order (spiral, diagonal, layer, rotate) or update in place - think boundaries, direction vectors and index maths.Memory hack Walk the walls, then shrink the room - four fences (top, bottom, left, right) close in after every lap.Open the Matrix Traversal guide →
09Bit Manipulation
3
Instinct Pairs that cancel, counting 1s, powers of two, subsets as numbers, or 'no + or - allowed' - drop to binary and use XOR, AND, OR and shifts.Memory hack XOR is a forgetful twin detector - see something twice and it vanishes; n & (n-1) snips off the last lit bulb.Open the Bit Manipulation guide →
10Bucket & Counting Sort
1
Instinct Keys live in a small, known range (letters, frequencies 1..n, bounded values) - index an array by the key instead of comparing, and get O(n).Memory hack Don't compare, just file it - every value walks straight to its own pigeonhole, then you read the shelves in order.Open the Bucket & Counting Sort guide →
11Linked List Techniques
7
Instinct Nodes joined by next pointers and the task is to reverse, splice, merge, reorder or remove in place - grab a dummy head and rewire pointers carefully.Memory hack Save next, flip, step - never let go of a rope before you've grabbed the next one.Open the Linked List Techniques guide →
12Fast & Slow Pointers
2
Instinct A next-step function you can follow (list nodes, digit-square sums, array-as-pointers) and you need a cycle, its entry, or the middle in O(1) space.Memory hack Tortoise and hare - on a loop track the hare laps the tortoise; restart the tortoise at the gate and they meet at the loop's door.Open the Fast & Slow Pointers guide →
13Stack
4
Instinct Things resolve in reverse order of arrival (brackets, adjacent pairs, nested expressions) - push now, pop when its partner shows up.Memory hack Last in, first out - like a pile of plates, you only ever touch the one on top; every closer pops its opener.Open the Stack guide →
14Monotonic Stack
2
Instinct Each element needs its nearest bigger or smaller neighbour (next warmer day, span, widest bar) - keep a sorted stack of waiting indices.Memory hack Tall people block the view - a newcomer kicks out everyone shorter waiting behind, and each kicked-out person just found their answer.Open the Monotonic Stack guide →
15Queue & Monotonic Deque
1
Instinct Arrival order matters, or you need the max/min of a moving window - reach for a FIFO queue, or a deque of indices kept in sorted order.Memory hack Old ones leave by the front door, weak ones get bounced out the back - so whoever stands at the front is always the champion.Open the Queue & Monotonic Deque guide →
16Data Structure Design
4
Instinct Implement a class whose methods must all hit a time bound (often O(1)) - write each method's target cost, then glue a hash map to a structure that keeps order.Memory hack Finder plus keeper - a hash map finds it fast, a list/heap/array keeps the order, and every method updates both.Open the Data Structure Design guide →
17Binary Search
6
Instinct Sorted data, a rotated array, or find the min/max X that works where a yes/no test flips only once - halve the search space every step.Memory hack Find the fence - every candidate reads NO NO NO YES YES, and binary search just walks to where the fence stands.Open the Binary Search guide →
18Recursion & Divide and Conquer
4
Instinct If the answer for n items can be built from the same problem on halves (or smaller pieces) plus a cheap combine step - split, recurse, merge.Memory hack Split it, trust it, stitch it - nail the base case, take the leap of faith on smaller calls, then glue their answers together.Open the Recursion & Divide and Conquer guide →
19Partitioning & Quickselect
2
Instinct Need the k-th smallest/largest, an unordered top-k, or values grouped into buckets in place - partition around a pivot and chase only one side.Memory hack Pivot, partition, pick a side - quickselect is quicksort's lazy cousin that only chases the half holding k.Open the Partitioning & Quickselect guide →
20Backtracking
5
Instinct Return ALL combinations, permutations, partitions or placements - or ask if any arrangement works - build a candidate step by step and undo each choice.Memory hack Choose, explore, un-choose - walk the decision tree and snip a branch the moment it can no longer succeed.Open the Backtracking guide →
21Greedy
3
Instinct An optimisation where one obvious local rule (earliest end, farthest reach, biggest first) never needs undoing - commit to it, then try hard to break it.Memory hack Grab the best bite now and never look back - but only once a counterexample hunt fails to make you regret it.Open the Greedy guide →
22Intervals & Line Sweep
3
Instinct See [start, end] pairs, meetings, bookings or the word "overlap"? Sort by an endpoint, then sweep left to right carrying one running fact.Memory hack Sort, then sweep - start time to merge, end time to choose, +1/-1 events to count the crowd.Open the Intervals & Line Sweep guide →
23Tree BFS (Level Order)
3
Instinct The answer talks about levels, rows, depth order, "closest to the root" or what you see from a side? Queue the tree and process it one level at a time.Memory hack Freeze the size, drain the row - read n = queue.size() before the loop and one level never bleeds into the next.Open the Tree BFS (Level Order) guide →
24Tree DFS
11
Instinct If the answer for a node can be built from the answers of its left and right subtrees, write one recursive function and trust it on the children.Memory hack Ask the kids, then decide - each child reports up, the parent combines, and a global variable keeps the best "bend" seen so far.Open the Tree DFS guide →
- 80Binary Tree Preorder TraversalEasy
- 81Symmetric TreeEasy
- 82Convert Sorted Array to Binary Search TreeEasy
- 83Binary Tree Postorder TraversalEasy
- 84Invert Binary TreeEasy
- 85Diameter of Binary TreeEasy
- 86Path Sum IIIMedium
- 87Construct Binary Tree from Preorder and Inorder TraversalMedium
- 88Lowest Common Ancestor of a Binary TreeMedium
- 89Serialize and Deserialize Binary TreeHard
- 90Binary Tree Maximum Path SumHard
25Binary Search Tree & In-order
4
Instinct The tree is a BST? Its in-order walk is a sorted list and every node splits the search space - think "sorted array in tree form", not "visit everything".Memory hack Left is less, right is more, in-order reads the sorted score - and every node lives inside a (low, high) fence set by its ancestors.Open the Binary Search Tree & In-order guide →
26Ordered Set (TreeMap)
3
Instinct Keys keep arriving or leaving and you must ask "what is the nearest key below/above x?" or "current min/max" each time - reach for TreeMap/TreeSet.Memory hack A HashMap with a sense of direction - floor looks down, ceiling looks up, and both answer in log time while the data keeps changing.Open the Ordered Set (TreeMap) guide →
27Trie
4
Instinct Many words, shared prefixes, and questions like "starts with", autocomplete, wildcard match or "search a board for all these words" - build a prefix tree.Memory hack Words share their beginnings, so store each beginning once - walk one letter per step, and an end flag marks where a real word stops.Open the Trie guide →
28Heap & Top-K
5
Instinct "K largest / smallest / closest / most frequent", or "always take the best available next"? Keep a heap - size k for top-K, or a ready-queue for scheduling.Memory hack Guard the top-K club with a bouncer - a min-heap of size k whose root is the weakest member; anyone stronger kicks them out.Open the Heap & Top-K guide →
29Two Heaps
2
Instinct When you need the middle of a changing collection, or best-of-one-pile fed by another pile, split it into a max-heap low half and a min-heap high half.Memory hack Small fries in a max-heap, big fish in a min-heap; the median lives on the shoreline between them.Open the Two Heaps guide →
30K-Way Merge
2
Instinct Several sorted lists, rows or streams and you need the global order, the k-th smallest or a range: keep one cursor per list in a min-heap.Memory hack Line up the heads, crown the smallest, then let its next-in-line step up.Open the K-Way Merge guide →
31Graph DFS
5
Instinct Connected regions, all paths, reachability, cloning or 2-colouring a graph or grid: dive from a node, mark it, recurse into unvisited neighbours.Memory hack Mark before you march: go deep, paint as you go, and back up only when every door is already painted.Open the Graph DFS guide →
32Graph BFS
3
Instinct Minimum moves, fewest steps or shortest transformation where every step costs the same: spread outward level by level with a queue.Memory hack Ripples in a pond: every ring is one step farther, so the first ring that touches the target is the answer.Open the Graph BFS guide →
33Topological Sort
1
Instinct Tasks with prerequisites, "X must come before Y", or an order hidden in comparisons: build a directed graph and peel off nodes with zero in-degree.Memory hack No prereqs? Off you go. Each finished task frees its followers; if someone is never freed, there is a cycle.Open the Topological Sort guide →
34Union-Find
2
Instinct Items get grouped by "connected", "same as" or "shares a" links and you keep asking which group something is in: merge sets with Union-Find.Memory hack Find your boss, merge the bosses; squash the chain (path compression) and hang the short tree under the tall one (rank).Open the Union-Find guide →
35Shortest Paths
3
Instinct Weighted edges plus "minimum cost, time or effort to reach" - grab a min-heap and always expand the cheapest unsettled node next (Dijkstra).Memory hack Pop the cheapest, skip the stale, relax the rest - Dijkstra is a ripple in a pond that touches near shores before far ones.Open the Shortest Paths guide →
36MST & Euler Paths
1
Instinct "Connect every point for the least total cost" means a minimum spanning tree; "use every edge or ticket exactly once" means an Euler path.Memory hack MST - grab the cheapest bridge that joins two separate islands. Euler - wander until stuck, write the stop down on the way back, then reverse.Open the MST & Euler Paths guide →
371-D Dynamic Programming
2
Instinct The best answer at position i depends only on a few earlier positions (i-1, i-2, ...) - write dp[i] from its predecessors, then roll it into variables.Memory hack Look back, pick best, roll forward - every step only remembers the last couple of stairs it stood on.Open the 1-D Dynamic Programming guide →
38Knapsack DP
4
Instinct Choose items to hit or stay under a target sum (can it be done, best value, fewest items, how many ways) - index a DP array by the remaining capacity.Memory hack Once? Walk back. Many? Walk forward. Each item used at most once loops capacity downward; reusable items loop it upward.Open the Knapsack DP guide →
39Longest Increasing Subsequence
2
Instinct Longest chain where each pick must beat the last (bigger, later, fits inside) - O(n²) best-ending-here DP, or O(n log n) tails plus binary search.Memory hack Patience solitaire - drop each card on the leftmost pile whose top is not smaller; the number of piles is the LIS length.Open the Longest Increasing Subsequence guide →
40Grid DP
4
Instinct Grid moves that never loop back (right/down, row to row) plus "count or optimise the paths" - build dp[r][c] from the cells that can step in.Memory hack Every cell asks its parents - a cell's answer comes only from the neighbours that can move into it, so fill cells in the order they arrive.Open the Grid DP guide →
41String DP
4
Instinct Two strings compared char by char (match, edit, interleave) means dp[i][j] over prefixes; one string's palindromes or splits means dp[l][r] or dp[i].Memory hack Match? Go diagonal. Mismatch? Ask the neighbours. Up drops a char from s, left drops one from t, diagonal uses both.Open the String DP guide →
42Tree & Graph DP
3
Instinct A node's best answer depends only on its children's answers - post-order DFS that returns a tiny tuple of states per node.Memory hack Kids report up, parent decides - every subtree hands its parent a small report card, and the parent never re-reads the kids' homework.Open the Tree & Graph DP guide →
43State Machine DP
1
Instinct Each step you are in one of a few modes (holding, sold, cooling down) with rules for switching - keep one DP value per mode and update all of them every step.Memory hack Name the moods, draw the moves, max the arrows - every arrow in your state diagram becomes exactly one line of code.Open the State Machine DP guide →
44Bitmask DP
2
Instinct n is tiny (about 20 or less) and you must use, visit or assign every item - make the set of used items a bitmask and DP over all 2^n subsets.Memory hack Small n, big choice - let the bits keep score: each item is a light switch and the mask is the whole switch panel.Open the Bitmask DP guide →
45Math & Geometry
3
Instinct Digits, factors, slopes or distances hide a formula - find the invariant, then guard against overflow, negatives and floating-point error.Memory hack Mod peels, gcd reduces, squares compare - and long saves the day. Peel digits with %10, reduce slopes with gcd, compare squared distances.Open the Math & Geometry guide →
No problems match these filters.
How to use this track
Pattern Wise 150 groups 150 essential interview problems by the pattern that solves them, from easy to hard inside each group. Working one pattern at a time builds the instinct to recognise it in a new problem.
Before each group, skim its pattern guide or the cheat sheet so you know the template. Then solve the problems in order: the early ones teach the idea, the later ones test whether you can adapt it.
Plan for one to three months at one or two problems a day. Use the revision list for problems you needed a hint on, and finish with a few timed mixed sessions so you also practise choosing the pattern.