300

3+ months

Pattern Wise 300

300 problems across every major pattern for complete, in-depth preparation.

300Problems
49Groups
48Easy
196Medium
56Hard
Start →
0%0 / 300
01

Array Manipulation

10
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. 3Remove Duplicates from Sorted ArrayEasy
  4. 4Best Time to Buy and Sell StockEasy
  5. 5Rotate ArrayMedium
  6. 6Product of Array Except SelfMedium
  7. 7Best Time to Buy and Sell Stock IIMedium
  8. 8Number of Zero-Filled SubarraysMedium
  9. 9Increasing Triplet SubsequenceMedium
  10. 10First Missing PositiveHard
02

String Manipulation

6
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. 11Is SubsequenceEasy
  2. 12Valid PalindromeEasy
  3. 13Longest Common PrefixEasy
  4. 14Zigzag ConversionMedium
  5. 15Reverse Words in a StringMedium
  6. 16Guess the WordHard
03

Hashing & Counting

13
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. 17Design HashMapEasy
  2. 18Maximum Number of BalloonsEasy
  3. 19Number of Good PairsEasy
  4. 20Isomorphic StringsEasy
  5. 21Ransom NoteEasy
  6. 22Contains Duplicate IIEasy
  7. 23Group AnagramsMedium
  8. 24Encode and Decode TinyURLMedium
  9. 25Reorganize StringMedium
  10. 26Longest Consecutive SequenceMedium
  11. 27Split Array into Consecutive SubsequencesMedium
  12. 28Number of Matching SubsequencesMedium
  13. 29Number of Good Ways to Split a StringMedium
04

Two Pointers

5
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. 30Merge Sorted ArrayEasy
  2. 31Two Sum II - Input Array Is SortedMedium
  3. 32Container With Most WaterMedium
  4. 333SumMedium
  5. 34Trapping Rain WaterHard
05

Sliding Window

10
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. 35Maximum Average Subarray IEasy
  2. 36Find All Anagrams in a StringMedium
  3. 37Permutation in StringMedium
  4. 38Maximum Sum of Distinct Subarrays With Length KMedium
  5. 39Longest Substring Without Repeating CharactersMedium
  6. 40Longest Repeating Character ReplacementMedium
  7. 41Minimum Size Subarray SumMedium
  8. 42Max Consecutive Ones IIIMedium
  9. 43Substring with Concatenation of All WordsHard
  10. 44Minimum Window SubstringHard
06

Prefix Sum

5
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. 45Range Sum Query - ImmutableEasy
  2. 46Subarray Sum Equals KMedium
  3. 47Subarray Sums Divisible by KMedium
  4. 48Continuous Subarray SumMedium
  5. 49Contiguous ArrayMedium
07

Kadane's Running Best

4
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. 50Maximum SubarrayMedium
  2. 51Maximum Sum Circular SubarrayMedium
  3. 52Maximum Product SubarrayMedium
  4. 53Best Sightseeing PairMedium
08

Matrix Traversal

5
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. 54Spiral MatrixMedium
  2. 55Rotate ImageMedium
  3. 56Set Matrix ZeroesMedium
  4. 57Valid SudokuMedium
  5. 58Game of LifeMedium
09

Bit Manipulation

7
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. 59Single NumberEasy
  2. 60Number of 1 BitsEasy
  3. 61Counting BitsEasy
  4. 62Reverse BitsEasy
  5. 63Bitwise AND of Numbers RangeMedium
  6. 64Single Number IIIMedium
  7. 65Sum of Two IntegersMedium
10

Bucket & Counting Sort

3
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. 66Sort Characters By FrequencyMedium
  2. 67Top K Frequent WordsMedium
  3. 68Maximum GapMedium
11

Linked List Techniques

14
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. 69Intersection of Two Linked ListsEasy
  2. 70Palindrome Linked ListEasy
  3. 71Reverse Linked ListEasy
  4. 72Design Linked ListMedium
  5. 73Remove Nth Node From End of ListMedium
  6. 74Remove Duplicates from Sorted List IIMedium
  7. 75Swap Nodes in PairsMedium
  8. 76Copy List with Random PointerMedium
  9. 77Partition ListMedium
  10. 78Rotate ListMedium
  11. 79Add Two NumbersMedium
  12. 80Flatten a Multilevel Doubly Linked ListMedium
  13. 81Reverse Linked List IIMedium
  14. 82Reverse Nodes in k-GroupHard
12

Fast & Slow Pointers

3
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. 83Middle of the Linked ListEasy
  2. 84Happy NumberEasy
  3. 85Linked List Cycle IIMedium
13

Stack

8
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. 86Valid ParenthesesEasy
  2. 87Remove All Adjacent Duplicates In StringEasy
  3. 88Min StackMedium
  4. 89Remove Duplicate LettersMedium
  5. 90Removing Stars From a StringMedium
  6. 91Evaluate Reverse Polish NotationMedium
  7. 92Basic Calculator IIMedium
  8. 93Longest Valid ParenthesesHard
14

Monotonic Stack

6
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. 94Next Greater Element IEasy
  2. 95Daily TemperaturesMedium
  3. 96Online Stock SpanMedium
  4. 97132 PatternMedium
  5. 98Number of Visible People in a QueueHard
  6. 99Largest Rectangle in HistogramHard
15

Queue & Monotonic Deque

7
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. 100Number of Recent CallsEasy
  2. 101Time Needed to Buy TicketsEasy
  3. 102Reveal Cards In Increasing OrderMedium
  4. 103Jump Game VIMedium
  5. 104Longest Continuous Subarray With Absolute Diff Less Than or Equal to LimitMedium
  6. 105Sliding Window MaximumHard
  7. 106Max Value of EquationHard
16

Data Structure Design

8
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. 107Design Browser HistoryMedium
  2. 108Time Based Key-Value StoreMedium
  3. 109Snapshot ArrayMedium
  4. 110Design TwitterMedium
  5. 111LRU CacheMedium
  6. 112Insert Delete GetRandom O(1)Medium
  7. 113Design a Food Rating SystemMedium
  8. 114Maximum Frequency StackHard
18

Recursion & Divide and Conquer

8
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. 125Merge Two Sorted ListsEasy
  2. 126Pow(x, n)Medium
  3. 127Decode StringMedium
  4. 128Convert Sorted List to Binary Search TreeMedium
  5. 129Construct Quad TreeMedium
  6. 130Maximum Binary TreeMedium
  7. 131Sort ListMedium
  8. 132Reverse PairsHard
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. 133Sort ColorsMedium
  2. 134Kth Largest Element in an ArrayMedium
20

Backtracking

8
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. 135Generate ParenthesesMedium
  2. 136PermutationsMedium
  3. 137SubsetsMedium
  4. 138Combination SumMedium
  5. 139Combination Sum IIMedium
  6. 140Letter Combinations of a Phone NumberMedium
  7. 141Palindrome PartitioningMedium
  8. 142N-QueensHard
21

Greedy

7
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. 143Jump Game IIMedium
  2. 144Minimum Add to Make Parentheses ValidMedium
  3. 145Gas StationMedium
  4. 146Task SchedulerMedium
  5. 147Minimum Cost to Hire K WorkersHard
  6. 148CandyHard
  7. 149Minimum Number of Refueling StopsHard
22

Intervals & Line Sweep

7
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. 150Merge IntervalsMedium
  2. 151Insert IntervalMedium
  3. 152Minimum Number of Arrows to Burst BalloonsMedium
  4. 153Maximum Number of Events That Can Be AttendedMedium
  5. 154Non-overlapping IntervalsMedium
  6. 155Minimum Interval to Include Each QueryHard
  7. 156The Skyline ProblemHard
23

Tree BFS (Level Order)

5
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. 157Binary Tree Level Order TraversalMedium
  2. 158Binary Tree Right Side ViewMedium
  3. 159Binary Tree Zigzag Level Order TraversalMedium
  4. 160Populating Next Right Pointers in Each Node IIMedium
  5. 161Maximum Width of Binary TreeMedium
24

Tree DFS

20
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. 162Binary Tree Preorder TraversalEasy
  2. 163Same TreeEasy
  3. 164Symmetric TreeEasy
  4. 165Binary Tree PathsEasy
  5. 166Convert Sorted Array to Binary Search TreeEasy
  6. 167Count Complete Tree NodesEasy
  7. 168Binary Tree Postorder TraversalEasy
  8. 169Invert Binary TreeEasy
  9. 170Diameter of Binary TreeEasy
  10. 171Path Sum IIIMedium
  11. 172Maximum Difference Between Node and AncestorMedium
  12. 173Construct Binary Tree from Preorder and Inorder TraversalMedium
  13. 174Construct Binary Tree from Inorder and Postorder TraversalMedium
  14. 175Delete Nodes And Return ForestMedium
  15. 176Lowest Common Ancestor of a Binary TreeMedium
  16. 177Find Duplicate SubtreesMedium
  17. 178Flatten Binary Tree to Linked ListMedium
  18. 179Distribute Coins in Binary TreeMedium
  19. 180Serialize and Deserialize Binary TreeHard
  20. 181Binary Tree Maximum Path SumHard
25

Binary Search Tree & In-order

6
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. 182Binary Tree Inorder TraversalEasy
  2. 183Minimum Distance Between BST NodesEasy
  3. 184Minimum Absolute Difference in BSTEasy
  4. 185Validate Binary Search TreeMedium
  5. 186Kth Smallest Element in a BSTMedium
  6. 187Binary Search Tree IteratorMedium
26

Ordered Set (TreeMap)

4
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. 188Trim a Binary Search TreeMedium
  2. 189My Calendar IMedium
  3. 190My Calendar IIMedium
  4. 191Stock Price FluctuationMedium
27

Trie

6
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. 192Implement Trie (Prefix Tree)Medium
  2. 193Design Add and Search Words Data StructureMedium
  3. 194Search Suggestions SystemMedium
  4. 195Longest Word in DictionaryMedium
  5. 196Maximum XOR of Two Numbers in an ArrayMedium
  6. 197Word Search IIHard
28

Heap & Top-K

6
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. 198Kth Largest Element in a StreamEasy
  2. 199Furthest Building You Can ReachMedium
  3. 200Single-Threaded CPUMedium
  4. 201Process Tasks Using ServersMedium
  5. 202Top K Frequent ElementsMedium
  6. 203K Closest Points to OriginMedium
29

Two Heaps

3
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. 204Find Median from Data StreamHard
  2. 205IPOHard
  3. 206Sliding Window MedianHard
30

K-Way Merge

4
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. 207Find K Pairs with Smallest SumsMedium
  2. 208Kth Smallest Element in a Sorted MatrixMedium
  3. 209Merge k Sorted ListsHard
  4. 210Smallest Range Covering Elements from K ListsHard
31

Fenwick & Segment Tree

2
Instinct Range sums, mins or counts asked again and again while values keep changing: prefix sums break, so reach for a Fenwick or segment tree.Memory hack Prefix sums freeze, trees breathe: climb by the last set bit (i & -i) for Fenwick, split in halves for segment trees.Open the Fenwick & Segment Tree guide →
  1. 211Range Sum Query - MutableMedium
  2. 212Count of Smaller Numbers After SelfHard
32

Graph DFS

10
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. 213Number of IslandsMedium
  2. 214Time Needed to Inform All EmployeesMedium
  3. 215All Paths From Source to TargetMedium
  4. 216Clone GraphMedium
  5. 217Is Graph Bipartite?Medium
  6. 218All Nodes Distance K in Binary TreeMedium
  7. 219Employee ImportanceMedium
  8. 220Surrounded RegionsMedium
  9. 221Pacific Atlantic Water FlowMedium
  10. 222Making A Large IslandHard
33

Graph BFS

6
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. 223Rotting OrangesMedium
  2. 22401 MatrixMedium
  3. 225Open the LockMedium
  4. 226Shortest Path in a Grid with Obstacles EliminationHard
  5. 227Bus RoutesHard
  6. 228Word LadderHard
34

Topological Sort

4
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. 229Course Schedule IIMedium
  2. 230Find Eventual Safe StatesMedium
  3. 231Minimum Height TreesMedium
  4. 232Sort Items by Groups Respecting DependenciesHard
35

Union-Find

4
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. 233Number of ProvincesMedium
  2. 234Redundant ConnectionMedium
  3. 235Accounts MergeMedium
  4. 236Minimize Malware SpreadHard
36

Shortest Paths

5
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. 237Network Delay TimeMedium
  2. 238Cheapest Flights Within K StopsMedium
  3. 239Path with Maximum ProbabilityMedium
  4. 240Path With Minimum EffortMedium
  5. 241Swim in Rising WaterHard
37

MST & Euler Paths

3
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. 242Min Cost to Connect All PointsMedium
  2. 243Reconstruct ItineraryHard
  3. 244Cracking the SafeHard
38

1-D Dynamic Programming

4
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. 245Climbing StairsEasy
  2. 246Min Cost Climbing StairsEasy
  3. 247House RobberMedium
  4. 248House Robber IIMedium
39

Knapsack DP

6
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. 249Partition Equal Subset SumMedium
  2. 250Target SumMedium
  3. 251Last Stone Weight IIMedium
  4. 252Coin ChangeMedium
  5. 253Coin Change IIMedium
  6. 254Perfect SquaresMedium
40

Longest Increasing Subsequence

3
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. 255Longest Increasing SubsequenceMedium
  2. 256Number of Longest Increasing SubsequenceMedium
  3. 257Russian Doll EnvelopesHard
41

Grid DP

9
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. 258Unique Paths IIMedium
  2. 259Minimum Path SumMedium
  3. 260TriangleMedium
  4. 261Count Square Submatrices with All OnesMedium
  5. 262Maximum Number of Points with CostMedium
  6. 263Maximum Profit in Job SchedulingHard
  7. 264Burst BalloonsHard
  8. 265Cherry PickupHard
  9. 266Longest Increasing Path in a MatrixHard
42

String DP

9
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. 267Longest Common SubsequenceMedium
  2. 268Longest Palindromic SubsequenceMedium
  3. 269Edit DistanceMedium
  4. 270Decode WaysMedium
  5. 271Word BreakMedium
  6. 272Interleaving StringMedium
  7. 273Wildcard MatchingHard
  8. 274Distinct SubsequencesHard
  9. 275Palindrome Partitioning IIHard
43

Tree & Graph DP

5
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. 276House Robber IIIMedium
  2. 277Unique Binary Search Trees IIMedium
  3. 278Number of Ways to Arrive at DestinationMedium
  4. 279Binary Tree CamerasHard
  5. 280Sum of Distances in TreeHard
44

State Machine DP

2
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. 281Best Time to Buy and Sell Stock with CooldownMedium
  2. 282Best Time to Buy and Sell Stock IIIHard
45

Bitmask DP

3
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. 283Minimum Number of Work Sessions to Finish the TasksMedium
  2. 284Fair Distribution of CookiesMedium
  3. 285Shortest Path Visiting All NodesHard
46

Digit DP

3
Instinct Count numbers in [L, R] (R up to 10^9 or 10^18) whose digits obey a rule - build the number digit by digit with a "still tight to N" flag.Memory hack Walk the digits on a leash - stay tight to N or break free, and once free you never go back. Remember PTLS - Position, Tight, Leading zero, State.Open the Digit DP guide →
  1. 286Count Numbers with Unique DigitsMedium
  2. 287Number of Digit OneHard
  3. 288Numbers At Most N Given Digit SetHard
47

Probability DP

3
Instinct Asked for a probability or expected value after random moves? Run DP over (step, state) and split each state's mass across every outcome.Memory hack Pour the probability like water - split it across the moves, let what spills off the board drain away, and the puddle that's left is your answer.Open the Probability DP guide →
  1. 289Knight Probability in ChessboardMedium
  2. 290Soup ServingsMedium
  3. 291New 21 GameMedium
48

Math & Geometry

6
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. 292Palindrome NumberEasy
  2. 293Reverse IntegerMedium
  3. 294Factorial Trailing ZeroesMedium
  4. 295Valid SquareMedium
  5. 296Minimum Area Rectangle IIMedium
  6. 297Max Points on a LineHard
49

String Matching

3
Instinct Find a pattern in a text, or a prefix that is also a suffix, faster than O(n·m) - reach for the KMP prefix function or a rolling hash.Memory hack KMP remembers borders, Rabin-Karp compares fingerprints - neither one re-reads text it has already seen.Open the String Matching guide →
  1. 298Repeated String MatchMedium
  2. 299Shortest PalindromeHard
  3. 300Longest Duplicate SubstringHard

How to use this track

Pattern Wise 300 is the complete set: every major pattern with enough problems to master its variations, including harder dynamic programming, graph and design problems that appear in senior interviews.

Treat it as a three-month plan or longer. Start each pattern with its guide, solve the easy and medium problems first, and only then attempt the hard ones. Write down the key insight for each hard problem in your notes.

If you have already finished Pattern Wise 150, filter this track to unsolved problems and focus on the patterns where your solve rate is lowest.