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
Start →
0%0 / 150
01

Array 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 →
  1. 1Move ZeroesEasy
  2. 2Majority ElementEasy
  3. 3Product of Array Except SelfMedium
  4. 4Best Time to Buy and Sell Stock IIMedium
  5. 5First Missing PositiveHard
02

String 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 →
  1. 6Is SubsequenceEasy
  2. 7Valid PalindromeEasy
  3. 8Reverse Words in a StringMedium
03

Hashing & 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 →
  1. 9Isomorphic StringsEasy
  2. 10Contains Duplicate IIEasy
  3. 11Group AnagramsMedium
  4. 12Encode and Decode TinyURLMedium
  5. 13Longest Consecutive SequenceMedium
04

Two 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 →
  1. 14Two Sum II - Input Array Is SortedMedium
  2. 15Container With Most WaterMedium
  3. 163SumMedium
  4. 17Trapping Rain WaterHard
05

Sliding 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 →
  1. 18Find All Anagrams in a StringMedium
  2. 19Permutation in StringMedium
  3. 20Longest Substring Without Repeating CharactersMedium
  4. 21Minimum Window SubstringHard
06

Prefix 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 →
  1. 22Range Sum Query - ImmutableEasy
  2. 23Subarray Sum Equals KMedium
  3. 24Contiguous ArrayMedium
07

Kadane'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 →
  1. 25Maximum SubarrayMedium
  2. 26Maximum Product SubarrayMedium
08

Matrix 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 →
  1. 27Spiral MatrixMedium
  2. 28Rotate ImageMedium
  3. 29Set Matrix ZeroesMedium
09

Bit 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 →
  1. 30Single NumberEasy
  2. 31Counting BitsEasy
  3. 32Single Number IIIMedium
10

Bucket & 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 →
  1. 33Top K Frequent WordsMedium
11

Linked 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 →
  1. 34Intersection of Two Linked ListsEasy
  2. 35Reverse Linked ListEasy
  3. 36Remove Nth Node From End of ListMedium
  4. 37Swap Nodes in PairsMedium
  5. 38Rotate ListMedium
  6. 39Add Two NumbersMedium
  7. 40Reverse Nodes in k-GroupHard
12

Fast & 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 →
  1. 41Middle of the Linked ListEasy
  2. 42Linked List Cycle IIMedium
13

Stack

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 →
  1. 43Valid ParenthesesEasy
  2. 44Min StackMedium
  3. 45Remove Duplicate LettersMedium
  4. 46Longest Valid ParenthesesHard
14

Monotonic 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 →
  1. 47Daily TemperaturesMedium
  2. 48Largest Rectangle in HistogramHard
15

Queue & 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 →
  1. 49Sliding Window MaximumHard
16

Data 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 →
  1. 50Design Browser HistoryMedium
  2. 51LRU CacheMedium
  3. 52Insert Delete GetRandom O(1)Medium
  4. 53Maximum Frequency StackHard
18

Recursion & 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 →
  1. 60Merge Two Sorted ListsEasy
  2. 61Decode StringMedium
  3. 62Convert Sorted List to Binary Search TreeMedium
  4. 63Sort ListMedium
19

Partitioning & 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 →
  1. 64Sort ColorsMedium
  2. 65Kth Largest Element in an ArrayMedium
20

Backtracking

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 →
  1. 66Generate ParenthesesMedium
  2. 67PermutationsMedium
  3. 68SubsetsMedium
  4. 69Palindrome PartitioningMedium
  5. 70N-QueensHard
21

Greedy

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 →
  1. 71Jump Game IIMedium
  2. 72Gas StationMedium
  3. 73Task SchedulerMedium
22

Intervals & 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 →
  1. 74Merge IntervalsMedium
  2. 75Insert IntervalMedium
  3. 76Non-overlapping IntervalsMedium
23

Tree 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 →
  1. 77Binary Tree Level Order TraversalMedium
  2. 78Binary Tree Right Side ViewMedium
  3. 79Populating Next Right Pointers in Each Node IIMedium
24

Tree 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 →
  1. 80Binary Tree Preorder TraversalEasy
  2. 81Symmetric TreeEasy
  3. 82Convert Sorted Array to Binary Search TreeEasy
  4. 83Binary Tree Postorder TraversalEasy
  5. 84Invert Binary TreeEasy
  6. 85Diameter of Binary TreeEasy
  7. 86Path Sum IIIMedium
  8. 87Construct Binary Tree from Preorder and Inorder TraversalMedium
  9. 88Lowest Common Ancestor of a Binary TreeMedium
  10. 89Serialize and Deserialize Binary TreeHard
  11. 90Binary Tree Maximum Path SumHard
25

Binary 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 →
  1. 91Binary Tree Inorder TraversalEasy
  2. 92Validate Binary Search TreeMedium
  3. 93Kth Smallest Element in a BSTMedium
  4. 94Binary Search Tree IteratorMedium
26

Ordered 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 →
  1. 95My Calendar IMedium
  2. 96My Calendar IIMedium
  3. 97Stock Price FluctuationMedium
27

Trie

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 →
  1. 98Implement Trie (Prefix Tree)Medium
  2. 99Design Add and Search Words Data StructureMedium
  3. 100Search Suggestions SystemMedium
  4. 101Word Search IIHard
28

Heap & 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 →
  1. 102Kth Largest Element in a StreamEasy
  2. 103Furthest Building You Can ReachMedium
  3. 104Single-Threaded CPUMedium
  4. 105Top K Frequent ElementsMedium
  5. 106K Closest Points to OriginMedium
29

Two 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 →
  1. 107Find Median from Data StreamHard
  2. 108IPOHard
30

K-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 →
  1. 109Kth Smallest Element in a Sorted MatrixMedium
  2. 110Merge k Sorted ListsHard
31

Graph 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 →
  1. 111Number of IslandsMedium
  2. 112Clone GraphMedium
  3. 113Is Graph Bipartite?Medium
  4. 114Surrounded RegionsMedium
  5. 115Pacific Atlantic Water FlowMedium
32

Graph 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 →
  1. 116Rotting OrangesMedium
  2. 11701 MatrixMedium
  3. 118Word LadderHard
33

Topological 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 →
  1. 119Course Schedule IIMedium
34

Union-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 →
  1. 120Number of ProvincesMedium
  2. 121Redundant ConnectionMedium
35

Shortest 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 →
  1. 122Network Delay TimeMedium
  2. 123Cheapest Flights Within K StopsMedium
  3. 124Swim in Rising WaterHard
36

MST & 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 →
  1. 125Min Cost to Connect All PointsMedium
37

1-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 →
  1. 126Climbing StairsEasy
  2. 127House Robber IIMedium
38

Knapsack 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 →
  1. 128Partition Equal Subset SumMedium
  2. 129Target SumMedium
  3. 130Coin ChangeMedium
  4. 131Coin Change IIMedium
39

Longest 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 →
  1. 132Longest Increasing SubsequenceMedium
  2. 133Russian Doll EnvelopesHard
40

Grid 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 →
  1. 134Unique Paths IIMedium
  2. 135Minimum Path SumMedium
  3. 136Count Square Submatrices with All OnesMedium
  4. 137Longest Increasing Path in a MatrixHard
41

String 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 →
  1. 138Longest Common SubsequenceMedium
  2. 139Longest Palindromic SubsequenceMedium
  3. 140Decode WaysMedium
  4. 141Word BreakMedium
42

Tree & 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 →
  1. 142House Robber IIIMedium
  2. 143Unique Binary Search Trees IIMedium
  3. 144Binary Tree CamerasHard
43

State 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 →
  1. 145Best Time to Buy and Sell Stock IIIHard
44

Bitmask 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 →
  1. 146Fair Distribution of CookiesMedium
  2. 147Shortest Path Visiting All NodesHard
45

Math & 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 →
  1. 148Palindrome NumberEasy
  2. 149Reverse IntegerMedium
  3. 150Max Points on a LineHard

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.