Join our mailing list Subscribe Us

DSA Interview Preparation

DSA Interview Curriculum · 72 Patterns

A complete practice system

Learn the patterns.
Earn the transfer.

Build transferable DSA interview skill through representative problems, deliberate variations, retention, and mixed practice.

257unique canonical problems
72 / 72patterns with assigned practice
210Core + Reinforcement problems
11mixed blind checkpoints

Three passes. A deliberate order.

Coverage before repetition; transfer after familiarity.

Follow the numbered curriculum within each pass and check its prerequisites. Stages organize the concepts; tiers set depth. Completing every pattern includes the Extension pass.

Core120 problems

Learn the foundational methods and their main interview applications. Work in curriculum order; write a proof idea and complexity before coding.

Reinforcement90 problems

Solve variations that expose missing conditions and combine patterns. Start mixing topics and hiding the method labels.

Extension47 problems

Complete all 72-pattern coverage, including specialist strings, digit/bitmask DP, range structures, and graph algorithms. Prioritize these after the general interview path unless your target role requires them.

Start here: Choose Core below. Before opening a learning note, try to explain which property permits a faster solution. Save the blind checkpoint problems for a mixed session and use the spreadsheet to record attempts, retention, and review dates.

The problem curriculum

Official links · assigned approaches · prerequisites

Learning notes start closed. Solve the problem first, then check the assigned approach: an accepted alternative may be correct without exercising the intended pattern. Problem numbering is stable across this reference and the tracker.

257 of 257 problemsProgress lives in the spreadsheet; this reference stores no personal data.
001

LeetCode 1·01 Arrays, hashing and sorting·Hashing

Reveal learning notes #01
What this teaches
Translate a pair constraint into a complement lookup while preserving distinct indices.
Target approach
One-pass value-to-index map; query before insertion.
Pattern coverage
#01 Hash lookup and frequency
002

LeetCode 49·01 Arrays, hashing and sorting·Hashing

Reveal learning notes #01
What this teaches
Design a canonical key that identifies an entire equivalence class.
Target approach
Map a fixed-alphabet character-count tuple to its group; discuss sorted-string keys.
Pattern coverage
#01 Hash lookup and frequency
Build on
Two Sum
004

LeetCode 303·01 Arrays, hashing and sorting·Prefix methods

Reveal learning notes #07
What this teaches
Answer static range queries through an identity prefix and an inverse aggregate.
Target approach
Build prefix[0]=0 and answer inclusive queries with prefix[right+1]-prefix[left].
Pattern coverage
#07 Prefix aggregates
005

LeetCode 560·01 Arrays, hashing and sorting·Prefix methods

Reveal learning notes #01, #08
What this teaches
Count earlier prefix states rather than attempting a sum window that fails with negatives.
Target approach
Seed frequency[0]=1; query prefix-k before recording the current prefix.
Pattern coverage
#01 Hash lookup and frequency; #08 Prefix sum plus hash map
006

LeetCode 1109·01 Arrays, hashing and sorting·Difference arrays

Reveal learning notes #09
What this teaches
Represent each offline range increment by two endpoint changes.
Target approach
Apply inclusive booking updates to a difference array, then reconstruct with a prefix sum.
Pattern coverage
#09 Difference array
007

LeetCode 53·01 Arrays, hashing and sorting·Contiguous optima

Reveal learning notes #10
What this teaches
Define the best nonempty subarray ending exactly at the current index.
Target approach
Kadane recurrence initialized from the first value; include an all-negative test.
Pattern coverage
#10 Kadane's maximum subarray
008

LeetCode 238·01 Arrays, hashing and sorting·Prefix and suffix

Reveal learning notes #11
What this teaches
Compose summaries from both sides without division, including zero-valued inputs.
Target approach
Write prefix products into output, then multiply by a running suffix product.
Pattern coverage
#11 Prefix-suffix composition
009

LeetCode 48·01 Arrays, hashing and sorting·Matrix simulation

Reveal learning notes Additional foundation
What this teaches
Derive the coordinate transformation and preserve unread values during an in-place permutation.
Target approach
Transpose then reverse rows, or rotate four-cell cycles; use O(1) auxiliary space.
Pattern coverage
A supporting interview technique outside the 72-pattern index.
010

LeetCode 54·01 Arrays, hashing and sorting·Matrix simulation

Reveal learning notes Additional foundation
What this teaches
Maintain shrinking boundaries and guard single remaining rows or columns.
Target approach
Four boundaries with explicit termination guards; output space excluded from auxiliary space.
Pattern coverage
A supporting interview technique outside the 72-pattern index.
Build on
Rotate Image
011

LeetCode 73·01 Arrays, hashing and sorting·Matrix simulation

Reveal learning notes Additional foundation
What this teaches
Reuse input storage as markers without confusing original values with newly written state.
Target approach
Use first row and column as markers plus separate flags; O(1) auxiliary space.
Pattern coverage
A supporting interview technique outside the 72-pattern index.
Build on
Rotate Image
012

LeetCode 912·01 Arrays, hashing and sorting·Sorting fundamentals

Reveal learning notes #70
What this teaches
Implement the divide, merge, and complexity argument behind a standard O(n log n) comparison sort.
Target approach
Implement merge sort without a library sort; later compare randomized quicksort and its worst case.
Pattern coverage
#70 Merge-sort counting / divide and conquer
013

LeetCode 217·01 Arrays, hashing and sorting·Hashing

Reveal learning notes #01
What this teaches
Use equality membership as the simplest hash-set invariant.
Target approach
Insert into a set and detect an existing value; compare expected linear time with sorting.
Pattern coverage
#01 Hash lookup and frequency
014

LeetCode 36·01 Arrays, hashing and sorting·Matrix simulation

Reveal learning notes #01
What this teaches
Encode row, column, and sub-box uniqueness constraints separately.
Target approach
Sets or masks for each row, column, and box; validate a board rather than solve it.
Pattern coverage
#01 Hash lookup and frequency
015

LeetCode 283·01 Arrays, hashing and sorting·In-place arrays

Reveal learning notes #03
What this teaches
Compact retained values stably while keeping an explicit write boundary.
Target approach
Read-write pointers in O(n) time and O(1) extra space.
Pattern coverage
#03 Read-write pointers
016

LeetCode 75·01 Arrays, hashing and sorting·In-place arrays

Reveal learning notes #03
What this teaches
Generalize compaction to three regions while preserving an explicit unknown region. Maintain three resolved regions while an unknown region shrinks.
Target approach
Dutch national flag partition with low, scan, and high boundaries; do not advance scan after every swap. Additional focus: Dutch national flag partition in one pass with O(1) auxiliary space.
Pattern coverage
#03 Read-write pointers
017

LeetCode 167·02 Two pointers and windows·Two pointers

Reveal learning notes #02
What this teaches
Use sorted order to justify discarding one endpoint after every comparison.
Target approach
Opposite-end pointers with an explicit argument for the chosen move.
Pattern coverage
#02 Opposite-end two pointers
018

LeetCode 15·02 Two pointers and windows·Two pointers

Reveal learning notes #02
What this teaches
Reduce a three-value search to a sorted pair scan without duplicate output.
Target approach
Sort; fix one value; use two pointers and deliberate duplicate skipping.
Pattern coverage
#02 Opposite-end two pointers
020

LeetCode 643·02 Two pointers and windows·Sliding windows

Reveal learning notes #04
What this teaches
Update a fixed-length aggregate in constant time by exchanging its two boundary contributions.
Target approach
Initialize exactly k elements, then subtract outgoing and add incoming values.
Pattern coverage
#04 Fixed-size sliding window
022

LeetCode 3·02 Two pointers and windows·Sliding windows

Reveal learning notes #01, #05
What this teaches
Maintain a longest feasible window when a newly repeated value invalidates uniqueness.
Target approach
Frequency window or last-seen indices; advance left monotonically.
Pattern coverage
#01 Hash lookup and frequency; #05 Variable-size sliding window
Build on
Two Sum
023

LeetCode 209·02 Two pointers and windows·Sliding windows

Reveal learning notes #05
What this teaches
Use positive values to justify repeatedly shrinking a qualifying sum window.
Target approach
Expand right and shrink while sum meets the threshold; state why negatives invalidate this proof.
Pattern coverage
#05 Variable-size sliding window
024

LeetCode 76·02 Two pointers and windows·Sliding windows

Reveal learning notes #01, #05
What this teaches
Distinguish covering all required multiplicities from merely containing distinct required symbols.
Target approach
Track required counts and satisfied requirements; shrink repeatedly only while the complete multiset is covered.
Pattern coverage
#01 Hash lookup and frequency; #05 Variable-size sliding window
025

LeetCode 992·02 Two pointers and windows·Exact counts

Reveal learning notes #01, #05, #06
What this teaches
Count every valid suffix and subtract adjacent at-most counts to obtain an exact count.
Target approach
Implement atMost(k)-atMost(k-1), returning zero for negative limits.
Pattern coverage
#01 Hash lookup and frequency; #05 Variable-size sliding window; #06 Exactly k via at-most counts
026

LeetCode 739·03 Stacks and monotonic structures·Monotonic stacks

Reveal learning notes #12
What this teaches
Keep unresolved indices until a later value permanently resolves their next-greater boundary.
Target approach
Decreasing stack of indices; pop and compute index distances when a warmer day arrives.
Pattern coverage
#12 Monotonic stack
028

LeetCode 239·03 Stacks and monotonic structures·Monotonic deques

Reveal learning notes #13
What this teaches
Separate candidate domination at the back from index expiration at the front.
Target approach
Decreasing deque of indices; expire before reading the current window maximum.
Pattern coverage
#13 Monotonic deque
029

LeetCode 20·03 Stacks and monotonic structures·Stacks and parsing

Reveal learning notes #14
What this teaches
Validate order and nesting by matching the most recent unmatched opening symbol.
Target approach
Stack with closing-to-opening mapping; reject mismatches and leftover openers.
Pattern coverage
#14 Stack for nested structure
030

LeetCode 150·03 Stacks and monotonic structures·Stacks and parsing

Reveal learning notes #14
What this teaches
Evaluate completed subexpressions while preserving noncommutative operand order.
Target approach
Value stack; pop right operand before left and implement truncation toward zero.
Pattern coverage
#14 Stack for nested structure
031

LeetCode 704·04 Binary search and intervals·Binary search

Reveal learning notes #15
What this teaches
Implement a shrinking search interval whose endpoints and failure behavior are unambiguous.
Target approach
Iterative binary search with a documented closed or half-open interval invariant.
Pattern coverage
#15 Binary search for a boundary
033

LeetCode 33·04 Binary search and intervals·Binary search

Reveal learning notes #15
What this teaches
Use the sorted half of a rotated array to determine which side can contain the target.
Target approach
Maintain target containment and identify the sorted half at every step; explain how this extends ordinary boundary search.
Pattern coverage
#15 Binary search for a boundary
034

LeetCode 74·04 Binary search and intervals·Binary search

Reveal learning notes #15
What this teaches
Exploit global row-to-row ordering to search a matrix as one virtual sorted array.
Target approach
Binary search a flattened index and map it to row and column.
Pattern coverage
#15 Binary search for a boundary
035

LeetCode 875·04 Binary search and intervals·Binary search on answers

Reveal learning notes #16
What this teaches
Turn minimum speed into a monotone time-feasibility predicate.
Target approach
Search the first speed whose summed ceiling-division hours fit h; use safe arithmetic.
Pattern coverage
#16 Binary search on the answer
037

LeetCode 56·04 Binary search and intervals·Intervals

Reveal learning notes #17
What this teaches
Summarize sorted overlapping intervals by one current merged range.
Target approach
Sort by start; extend the current end or emit a completed range; state touching-endpoint semantics.
Pattern coverage
#17 Sort and merge intervals
038

CSES 1619·04 Binary search and intervals·Sweep lines

Reveal learning notes #18
What this teaches
Replace continuous time with the finite set of arrivals and departures.
Target approach
Sort signed endpoint events and track the running maximum; the official task guarantees all times are distinct.
Pattern coverage
#18 Sweep line and events
039

LeetCode 141·05 Linked lists and data-structure design·Linked lists

Reveal learning notes #23
What this teaches
Detect repeated node identities without storing every visited node.
Target approach
Floyd slow/fast traversal with null checks; reason about relative motion in a cycle.
Pattern coverage
#23 Fast-slow pointers
040

LeetCode 206·05 Linked lists and data-structure design·Linked lists

Reveal learning notes #24
What this teaches
Reverse links while keeping access to the unreversed suffix.
Target approach
Iterative previous/current/next pointer reversal; preserve the next node before redirecting the link.
Pattern coverage
#24 Linked-list reversal
041

LeetCode 21·05 Linked lists and data-structure design·Linked-list fundamentals

Reveal learning notes Additional foundation
What this teaches
Merge through node identities and preserve both input continuations while rewiring links.
Target approach
Dummy-head iterative merge of two sorted lists, followed by attaching the remaining tail.
Pattern coverage
A supporting interview technique outside the 72-pattern index.
042

LeetCode 143·05 Linked lists and data-structure design·Linked lists

Reveal learning notes #23, #24
What this teaches
Compose midpoint detection, reversal, and alternating merge without introducing a cycle.
Target approach
Find the middle, split the list, reverse the second half, and weave nodes in place.
Pattern coverage
#23 Fast-slow pointers; #24 Linked-list reversal
043

LeetCode 19·05 Linked lists and data-structure design·Linked-list fundamentals

Reveal learning notes Additional foundation
What this teaches
Use a fixed pointer gap to turn distance from the tail into one forward traversal.
Target approach
Dummy head and two pointers separated by n nodes; unlink the target through its predecessor.
Pattern coverage
A supporting interview technique outside the 72-pattern index.
044

LeetCode 146·05 Linked lists and data-structure design·Data structure design

Reveal learning notes #71
What this teaches
Constant-time lookup and recency order require a hash map and a directly unlinkable ordered structure.
Target approach
Implement a hash map to doubly linked nodes plus sentinel head/tail; maintain map/list consistency on get, overwrite, insertion, and eviction.
Pattern coverage
#71 Composite structures for operation guarantees
045

LeetCode 380·05 Linked lists and data-structure design·Data structure design

Reveal learning notes #71
What this teaches
Constant-time uniform sampling needs dense random-access storage, so deletion swaps with the final element.
Target approach
Combine a dynamic array with a value-to-index map, perform swap-and-pop deletion, and sample an array index uniformly.
Pattern coverage
#71 Composite structures for operation guarantees
046

LeetCode 155·05 Linked lists and data-structure design·Design fundamentals

Reveal learning notes #14, #71
What this teaches
Maintain a second invariant so minimum queries remain constant-time under pops.
Target approach
Stack plus per-level minimum, or a synchronized minimum stack.
Pattern coverage
#14 Stack for nested structure; #71 Composite structures for operation guarantees
047

LeetCode 232·05 Linked lists and data-structure design·Design fundamentals

Reveal learning notes #71
What this teaches
Distinguish amortized cost from the cost of one transfer operation.
Target approach
Two stacks; transfer only when the output stack is empty. Prove amortized O(1) operations.
Pattern coverage
#71 Composite structures for operation guarantees
048

LeetCode 2·05 Linked lists and data-structure design·Linked-list fundamentals

Reveal learning notes Additional foundation
What this teaches
Propagate arithmetic carry through unequal-length lists and a possible final node.
Target approach
Iterative digit addition using a dummy head and carry; account for output space.
Pattern coverage
A supporting interview technique outside the 72-pattern index.
049

LeetCode 215·06 Heaps and greedy scheduling·Selection and top k

Reveal learning notes #19, #22
What this teaches
Compare a bounded heap against in-place rank selection without confusing selection with sorting.
Target approach
Implement both a size-k min-heap and randomized three-way quickselect; explain their separate worst-case guarantees.
Pattern coverage
#19 Heap for top k; #22 Quickselect
050

LeetCode 347·06 Heaps and greedy scheduling·Selection and top k

Reveal learning notes #01, #19
What this teaches
Separate frequency aggregation from selecting the most frequent distinct keys.
Target approach
Count frequencies, then retain a heap of k entries; discuss a bucket alternative after the target solution.
Pattern coverage
#01 Hash lookup and frequency; #19 Heap for top k
052

LeetCode 23·06 Heaps and greedy scheduling·K-way merging

Reveal learning notes #20
What this teaches
Expose only one candidate per sorted source instead of heapifying every node.
Target approach
Min-heap of list heads with safe tie-breaking; pop a node and push its successor.
Pattern coverage
#20 Heap for k-way merge
053

LeetCode 295·06 Heaps and greedy scheduling·Streaming median

Reveal learning notes #21
What this teaches
Maintain both ordering and size-balance invariants across two priority queues.
Target approach
Lower max-heap and upper min-heap; rebalance after insertions and query their roots.
Pattern coverage
#21 Two heaps for a median
054

LeetCode 435·06 Heaps and greedy scheduling·Greedy proofs

Reveal learning notes #50
What this teaches
Keeping the greatest number of compatible intervals is equivalent to deleting the fewest intervals.
Target approach
Sort by end time and retain each compatible interval; give an exchange argument for choosing the earliest finishing interval.
Pattern coverage
#50 Greedy choice with an exchange proof
055

LeetCode 55·06 Heaps and greedy scheduling·Greedy proofs

Reveal learning notes #50
What this teaches
Reachability can be summarized by the farthest reachable index instead of recording every path.
Target approach
Maintain the farthest reachable boundary and fail exactly when the next index lies beyond it.
Pattern coverage
#50 Greedy choice with an exchange proof
056

LeetCode 45·06 Heaps and greedy scheduling·Greedy proofs

Reveal learning notes #50
What this teaches
Minimum jumps needs layer boundaries in addition to a farthest-reach invariant.
Target approach
Scan the current reachable layer, accumulate the next farthest boundary, and increment jumps only when the current layer ends.
Pattern coverage
#50 Greedy choice with an exchange proof
Build on
Jump Game
057

LeetCode 763·06 Heaps and greedy scheduling·Greedy proofs

Reveal learning notes #50
What this teaches
The last occurrence of every included symbol forces the earliest possible end of a valid partition.
Target approach
Precompute last occurrences and extend a partition boundary until the scan reaches the maximum forced endpoint.
Pattern coverage
#50 Greedy choice with an exchange proof
058

CSES 1164·06 Heaps and greedy scheduling·Heap scheduling

Reveal learning notes #51
What this teaches
Assigning every booking to a room minimizes resources, unlike selecting a subset of bookings.
Target approach
Sort arrivals and use a min-heap of (departure, room ID); reuse only when departure < arrival because occupied booking endpoints are inclusive.
Pattern coverage
#51 Greedy scheduling with a heap
059

LeetCode 1353·06 Heaps and greedy scheduling·Heap scheduling

Reveal learning notes #51
What this teaches
When only one event can be attended per day, the soonest-expiring currently available event is the safest choice.
Target approach
Sweep days, add newly available events to a minimum-end-day heap, discard expired events, and attend one event per day; jump over empty periods.
Pattern coverage
#51 Greedy scheduling with a heap
061

LeetCode 104·07 Trees and BSTs·Tree foundations

Reveal learning notes #36
What this teaches
Define a recursive return contract and derive a parent result from child results.
Target approach
Postorder DFS with an empty-tree base case; also write iterative DFS.
Pattern coverage
#36 Tree postorder DP
072

LeetCode 94·07 Trees and BSTs·Tree foundations

Reveal learning notes Additional foundation
What this teaches
Understand left-node-right traversal and its explicit-stack state.
Target approach
Implement both recursive and iterative inorder traversal of a general binary tree.
Pattern coverage
A supporting interview technique outside the 72-pattern index.
073

LeetCode 112·07 Trees and BSTs·Tree foundations

Reveal learning notes #25
What this teaches
Distinguish root-to-leaf paths from paths allowed to stop at any node.
Target approach
DFS carrying a remaining target or running sum; accept only at a leaf.
Pattern coverage
#25 DFS / flood fill
074

LeetCode 200·08 Graphs and shortest paths·Graph traversal

Reveal learning notes #25
What this teaches
Start one traversal per unseen component and mark vertices on discovery.
Target approach
Iterative DFS and BFS flood fill; explain O(rows × columns) total work.
Pattern coverage
#25 DFS / flood fill
075

LeetCode 133·08 Graphs and shortest paths·Graph traversal

Reveal learning notes #25
What this teaches
Separate node identity from node value and cache each clone before visiting its neighbors.
Target approach
DFS or BFS with an original-node to cloned-node map.
Pattern coverage
#25 DFS / flood fill
076

LeetCode 130·08 Graphs and shortest paths·Graph traversal

Reveal learning notes #25
What this teaches
Reverse the question by preserving every region connected to a boundary.
Target approach
Boundary-seeded flood fill followed by a board sweep.
Pattern coverage
#25 DFS / flood fill
077

LeetCode 417·08 Graphs and shortest paths·Graph traversal

Reveal learning notes #25, #68
What this teaches
Reverse directed movement and intersect two independently reachable sets. Searching backward from each destination boundary replaces a separate downhill search from every cell.
Target approach
Two reverse flood fills from the ocean boundaries. Additional focus: Run two reverse flood fills from the ocean boundaries along nondecreasing heights and intersect the reachable sets.
Pattern coverage
#25 DFS / flood fill; #68 Reverse reasoning / reverse graph
078

LeetCode 994·08 Graphs and shortest paths·Shortest paths

Reveal learning notes #26
What this teaches
Model simultaneous spread by enqueuing every initial source at time zero.
Target approach
Multi-source BFS with level or distance tracking.
Pattern coverage
#26 BFS / multi-source BFS
079

LeetCode 127·08 Graphs and shortest paths·Shortest paths

Reveal learning notes #26
What this teaches
Build an implicit unweighted graph without confusing a word transformation with string DP.
Target approach
BFS with wildcard buckets or generated one-letter neighbors; then explain bidirectional BFS.
Pattern coverage
#26 BFS / multi-source BFS
080

LeetCode 743·08 Graphs and shortest paths·Weighted graphs

Reveal learning notes #28
What this teaches
Finalize a nonnegative shortest distance when its current minimum heap entry is removed.
Target approach
Dijkstra with an adjacency list, a min-heap, and stale-entry checks.
Pattern coverage
#28 Dijkstra's shortest paths
081

LeetCode 787·08 Graphs and shortest paths·Weighted graphs

Reveal learning notes #29
What this teaches
A stop limit makes edge count part of the state and requires previous-round snapshots.
Target approach
Bounded Bellman–Ford for at most k + 1 edges, copying distances between rounds.
Pattern coverage
#29 Bellman–Ford
082

LeetCode 207·08 Graphs and shortest paths·Dependencies

Reveal learning notes #31, #35
What this teaches
Distinguish a node already seen from a node active on the current directed DFS path.
Target approach
Implement three-color DFS for cycle detection and explain the Kahn indegree alternative.
Pattern coverage
#31 Topological ordering / DAG DP; #35 DFS cycle states / strongly connected components
083

LeetCode 210·08 Graphs and shortest paths·Dependencies

Reveal learning notes #31
What this teaches
Produce a dependency order and reject a graph when fewer than all vertices are processed.
Target approach
Kahn topological ordering with indegree updates.
Pattern coverage
#31 Topological ordering / DAG DP
084

LeetCode 684·08 Graphs and shortest paths·Connectivity

Reveal learning notes #32
What this teaches
An undirected edge closes a cycle exactly when its endpoints are already connected.
Target approach
DSU with path compression and union by size or rank.
Pattern coverage
#32 Union–find / disjoint-set union
085

LeetCode 721·08 Graphs and shortest paths·Connectivity

Reveal learning notes #32
What this teaches
Build components from shared identifiers while retaining original record metadata.
Target approach
DSU over accounts or emails, then collect and sort each component.
Pattern coverage
#32 Union–find / disjoint-set union
086

LeetCode 1584·08 Graphs and shortest paths·Connectivity

Reveal learning notes #32, #33
What this teaches
Minimizing total network cost differs from minimizing distance from one source.
Target approach
Kruskal with DSU; also implement dense O(n²) Prim to avoid storing all pairwise edges.
Pattern coverage
#32 Union–find / disjoint-set union; #33 Minimum spanning tree
087

LeetCode 785·08 Graphs and shortest paths·Connectivity

Reveal learning notes #34
What this teaches
Opposite-group constraints require coloring every connected component and detecting equal-color edges.
Target approach
BFS or DFS two-coloring; explain the odd-cycle obstruction.
Pattern coverage
#34 Bipartite coloring
088

LeetCode 78·09 Backtracking and tries·Backtracking

Reveal learning notes #49
What this teaches
Independent include/exclude choices generate a power set; the output itself is exponential.
Target approach
Implement include/exclude DFS with one mutable path and copy only when recording an answer.
Pattern coverage
#49 Backtracking and pruning
089

LeetCode 46·09 Backtracking and tries·Backtracking

Reveal learning notes #49
What this teaches
Permutations require tracking used positions, unlike increasing-index subset generation.
Target approach
Use choose/recurse/undo with a used array or in-place swapping; explain why each ordering appears once.
Pattern coverage
#49 Backtracking and pruning
Build on
Subsets
090

LeetCode 39·09 Backtracking and tries·Backtracking

Reveal learning notes #49
What this teaches
Unlimited reuse changes the next recursion index and permits target-based pruning only because values are positive.
Target approach
Sort candidates, recurse from a nondecreasing candidate index, allow reuse of that index, and prune when the candidate exceeds the remaining target.
Pattern coverage
#49 Backtracking and pruning
Build on
Subsets
091

LeetCode 22·09 Backtracking and tries·Backtracking

Reveal learning notes #49
What this teaches
A global validity requirement becomes a prefix invariant that rejects invalid branches early.
Target approach
Track opened and closed parentheses; add a closing parenthesis only while closed < opened and open at most n pairs.
Pattern coverage
#49 Backtracking and pruning
Build on
Subsets
092

LeetCode 208·09 Backtracking and tries·Tries

Reveal learning notes #53
What this teaches
Whole-word membership and prefix membership differ only at the terminal marker.
Target approach
Implement insert, search, and startsWith with explicit trie nodes and word-end flags.
Pattern coverage
#53 Trie / prefix tree
094

LeetCode 79·09 Backtracking and tries·Backtracking

Reveal learning notes #49
What this teaches
Undo per-path visited state without mixing different starting cells or branches.
Target approach
DFS choose-mark-explore-unmark; never reuse a cell within one word path.
Pattern coverage
#49 Backtracking and pruning
095

LeetCode 329·10 Dynamic programming·Dependencies

Reveal learning notes #31, #39
What this teaches
Strictly increasing transitions turn a seemingly cyclic grid into a DAG.
Target approach
Memoized DFS or topological DAG DP; cache the longest path beginning at each cell.
Pattern coverage
#31 Topological ordering / DAG DP; #39 Memoization / one-dimensional DP
096

LeetCode 70·10 Dynamic programming·DP foundations

Reveal learning notes #39
What this teaches
Choose a state, base cases, and recurrence before compressing memory.
Target approach
Memoized recursion, tabulation, then a two-value rolling recurrence.
Pattern coverage
#39 Memoization / one-dimensional DP
097

LeetCode 198·10 Dynamic programming·DP foundations

Reveal learning notes #39, #48
What this teaches
A prefix optimum must compare taking the current item with skipping it.
Target approach
Take/skip or prefix DP, then constant-space compression.
Pattern coverage
#39 Memoization / one-dimensional DP; #48 Finite-state DP: stock / cooldown
098

LeetCode 152·10 Dynamic programming·DP foundations

Reveal learning notes #39, #48
What this teaches
A negative factor swaps the roles of the largest and smallest products ending at the previous position.
Target approach
Track both minimum and maximum products ending here, using previous-state snapshots and handling zero resets.
Pattern coverage
#39 Memoization / one-dimensional DP; #48 Finite-state DP: stock / cooldown
Build on
House Robber
099

LeetCode 91·10 Dynamic programming·DP foundations

Reveal learning notes #39
What this teaches
Zero and two-digit validity rules determine which prefix transitions exist.
Target approach
Prefix or suffix DP with explicit single-digit and double-digit guards.
Pattern coverage
#39 Memoization / one-dimensional DP
100

LeetCode 139·10 Dynamic programming·DP foundations

Reveal learning notes #39
What this teaches
Segmenting a string is reachability between valid prefix boundaries.
Target approach
Boolean prefix DP or memoized suffix DP with dictionary lookup.
Pattern coverage
#39 Memoization / one-dimensional DP
Build on
Decode Ways
101

LeetCode 62·10 Dynamic programming·Grid DP

Reveal learning notes #40
What this teaches
Acyclic movement makes each cell depend only on already solved predecessors.
Target approach
Two-dimensional path-count DP, then row compression.
Pattern coverage
#40 Grid DP
102

LeetCode 64·10 Dynamic programming·Grid DP

Reveal learning notes #40
What this teaches
The same grid dependency graph can optimize a cost instead of counting routes.
Target approach
Minimum-cost grid DP with valid unreachable-state initialization.
Pattern coverage
#40 Grid DP
Build on
Unique Paths
103

LeetCode 221·10 Dynamic programming·Grid DP

Reveal learning notes #40
What this teaches
A cell summarizes the largest valid structure ending there rather than a route to it.
Target approach
DP using one plus the minimum of left, up, and diagonal sizes.
Pattern coverage
#40 Grid DP
105

LeetCode 494·10 Dynamic programming·Knapsack

Reveal learning notes #41
What this teaches
Convert sign choices to counting subsets while preserving parity, range, and zero multiplicity.
Target approach
Counting 0/1 knapsack after deriving the target subset sum, or equivalent signed-sum DP.
Pattern coverage
#41 0/1 knapsack / subset sum
106

LeetCode 322·10 Dynamic programming·Knapsack

Reveal learning notes #42
What this teaches
Repeatable choices permit transitions from already reachable smaller amounts.
Target approach
Unbounded minimum-count DP with an impossible-state sentinel.
Pattern coverage
#42 Unbounded knapsack / coin change
107

LeetCode 518·10 Dynamic programming·Knapsack

Reveal learning notes #42
What this teaches
Type-first iteration counts unordered combinations without counting their permutations.
Target approach
Unbounded counting DP with coins outside and increasing amounts inside.
Pattern coverage
#42 Unbounded knapsack / coin change
Build on
Coin Change
108

LeetCode 1143·10 Dynamic programming·Sequence DP

Reveal learning notes #43
What this teaches
Two prefix indices preserve which elements remain available in each sequence.
Target approach
Two-sequence DP with match and skip transitions; reconstruct one optimal subsequence.
Pattern coverage
#43 Two-sequence DP: LCS / edit distance
109

LeetCode 72·10 Dynamic programming·Sequence DP

Reveal learning notes #43
What this teaches
Each allowed edit changes one or both prefix indices with its own transition cost.
Target approach
Prefix DP over insert, delete, and replace with empty-prefix boundaries.
Pattern coverage
#43 Two-sequence DP: LCS / edit distance
110

LeetCode 300·10 Dynamic programming·Sequence DP

Reveal learning notes #44
What this teaches
A minimal tail per length dominates larger tails without preserving a complete answer sequence.
Target approach
First quadratic predecessor DP, then lower-bound tails; reconstruct using predecessor indices.
Pattern coverage
#44 Longest increasing subsequence: tails
113

LeetCode 28·11 Strings, bits and mathematics·Exact string matching

Reveal learning notes #54
What this teaches
A mismatch can reuse a matched border instead of restarting the text scan.
Target approach
Implement KMP prefix-function preprocessing and search from scratch; do not use a substring-search built-in.
Pattern coverage
#54 KMP / Z-function matching
114

LeetCode 5·11 Strings, bits and mathematics·Palindromes

Reveal learning notes #56
What this teaches
Contiguous palindromes are characterized by odd and even centers, unlike palindromic subsequences.
Target approach
Expand around every odd and even center and retain the longest interval.
Pattern coverage
#56 Palindrome centers / palindrome DP
115

LeetCode 647·11 Strings, bits and mathematics·Palindromes

Reveal learning notes #56
What this teaches
Counting all palindromic spans can reuse the truth value for the interval with both endpoints removed.
Target approach
Implement interval DP with length-one and length-two base cases and count all true intervals; then compare memory with center expansion.
Pattern coverage
#56 Palindrome centers / palindrome DP
116

LeetCode 136·11 Strings, bits and mathematics·Bits

Reveal learning notes #57
What this teaches
XOR cancellation works only because every other value has even multiplicity.
Target approach
XOR all values and explicitly use associativity, commutativity, and x XOR x = 0 in the explanation.
Pattern coverage
#57 XOR, bit masks, and bit counts
117

LeetCode 191·11 Strings, bits and mathematics·Bits

Reveal learning notes #57
What this teaches
Clearing the lowest set bit counts only the bits that are present.
Target approach
Use n &= n - 1 until zero and state the input width assumptions.
Pattern coverage
#57 XOR, bit masks, and bit counts
118

LeetCode 338·11 Strings, bits and mathematics·Bits

Reveal learning notes #57
What this teaches
Neighboring integers share a smaller bit-count subproblem.
Target approach
Derive and implement either bits[i] = bits[i >> 1] + (i & 1) or bits[i] = bits[i & (i - 1)] + 1.
Pattern coverage
#57 XOR, bit masks, and bit counts
119

LeetCode 1071·11 Strings, bits and mathematics·Arithmetic

Reveal learning notes #58
What this teaches
String repetition compatibility must hold before a gcd of lengths identifies a common repeated block.
Target approach
Check that str1 + str2 equals str2 + str1, then compute the length with Euclid and return that prefix.
Pattern coverage
#58 GCD and modular arithmetic
120

LeetCode 307·12 Advanced queries and reductions·Range structures

Reveal learning notes #60
What this teaches
Point replacements plus range sums can be converted to additive updates and two prefix queries.
Target approach
Implement a Fenwick tree, keep old values to convert replacements to deltas, and compute sums by prefix subtraction.
Pattern coverage
#60 Fenwick tree / binary indexed tree
121

LeetCode 128·01 Arrays, hashing and sorting·Hashing

Reveal learning notes #01
What this teaches
Avoid rescanning every chain by expanding only from values with no predecessor.
Target approach
Hash set plus run-start test; prove each distinct value is visited only a constant number of times.
Pattern coverage
#01 Hash lookup and frequency
Build on
Two Sum
124

LeetCode 525·01 Arrays, hashing and sorting·Prefix methods

Reveal learning notes #01, #08
What this teaches
Use earliest occurrences instead of frequencies when the objective changes from counting to longest length.
Target approach
Map 0 to -1 and 1 to +1; retain the first index of every balance, including the empty prefix.
Pattern coverage
#01 Hash lookup and frequency; #08 Prefix sum plus hash map
125

LeetCode 974·01 Arrays, hashing and sorting·Prefix methods

Reveal learning notes #01, #08
What this teaches
Replace exact prefix sums by equivalence classes modulo k.
Target approach
Count matching normalized prefix remainders; handle the language-specific behavior of negative remainders.
Pattern coverage
#01 Hash lookup and frequency; #08 Prefix sum plus hash map
126

LeetCode 918·01 Arrays, hashing and sorting·Contiguous optima

Reveal learning notes #10
What this teaches
Split circular optima into an ordinary segment or the complement of a minimum segment.
Target approach
Run maximum and minimum Kadane with the total sum; guard the all-negative case.
Pattern coverage
#10 Kadane's maximum subarray
127

LeetCode 493·01 Arrays, hashing and sorting·Merge counting

Reveal learning notes #70
What this teaches
The doubled-value inequality must be counted independently of the ordinary merge comparison.
Target approach
Use merge sort with a separate monotone cross-half counting pass for leftValue > 2 * rightValue and wide arithmetic.
Pattern coverage
#70 Merge-sort counting / divide and conquer
128

LeetCode 289·01 Arrays, hashing and sorting·Matrix simulation

Reveal learning notes #57
What this teaches
Update every cell simultaneously while retaining each neighbor's old state.
Target approach
Encode old and new states in separate bits, then commit in a second pass.
Pattern coverage
#57 XOR, bit masks, and bit counts
129

LeetCode 41·01 Arrays, hashing and sorting·In-place arrays

Reveal learning notes Additional foundation
What this teaches
Use the bounded useful value domain as an implicit index map without extra storage.
Target approach
Cyclic placement or sign marking; prove O(n) work and handle duplicates safely.
Pattern coverage
A supporting interview technique outside the 72-pattern index.
Build on
Sort Colors
130

LeetCode 31·01 Arrays, hashing and sorting·Array construction

Reveal learning notes Additional foundation
What this teaches
Derive a lexicographic successor by changing the rightmost possible pivot.
Target approach
Find the decreasing suffix, swap the pivot with its smallest larger successor, then reverse the suffix.
Pattern coverage
A supporting interview technique outside the 72-pattern index.
Build on
Sort Colors
131

LeetCode 42·02 Two pointers and windows·Two pointers

Reveal learning notes #02, #11
What this teaches
Recognize both an all-other-position decomposition and an equivalent constant-space boundary invariant.
Target approach
First implement prefix/suffix maxima; then derive the two-pointer running-maxima solution.
Pattern coverage
#02 Opposite-end two pointers; #11 Prefix-suffix composition
132

LeetCode 424·02 Two pointers and windows·Sliding windows

Reveal learning notes #01, #05
What this teaches
Express replacement feasibility as window length minus a dominant-character frequency.
Target approach
Maintain a count window and prove the chosen maximum-frequency bookkeeping, including any stale-maximum optimization.
Pattern coverage
#01 Hash lookup and frequency; #05 Variable-size sliding window
134

LeetCode 1248·02 Two pointers and windows·Exact counts

Reveal learning notes #05, #06
What this teaches
Transfer the exactly-k identity from distinct values to a marked-element count.
Target approach
Treat odd numbers as marked; subtract two at-most counters and compare with a prefix-count alternative.
Pattern coverage
#05 Variable-size sliding window; #06 Exactly k via at-most counts
135

LeetCode 907·03 Stacks and monotonic structures·Monotonic stacks

Reveal learning notes #12
What this teaches
Count each element's contribution while assigning duplicate minima to exactly one owner.
Target approach
Previous/next smaller spans with asymmetric strictness, then sum value*leftChoices*rightChoices.
Pattern coverage
#12 Monotonic stack
136

LeetCode 402·03 Stacks and monotonic structures·Monotonic stacks

Reveal learning notes #12
What this teaches
Combine a monotone stack with a limited removal budget and lexicographic optimality.
Target approach
Pop larger preceding digits while deletions remain; remove leftover suffix digits and normalize leading zeroes.
Pattern coverage
#12 Monotonic stack
137

LeetCode 1438·03 Stacks and monotonic structures·Monotonic deques

Reveal learning notes #05, #13
What this teaches
Maintain both extrema while a variable-length window moves.
Target approach
One increasing and one decreasing deque; shrink until maximum-minus-minimum fits the limit.
Pattern coverage
#05 Variable-size sliding window; #13 Monotonic deque
138

LeetCode 394·03 Stacks and monotonic structures·Stacks and parsing

Reveal learning notes #14
What this teaches
Suspend the current parse frame when entering nested repetition.
Target approach
Stack of repeat counts and accumulated parent fragments; account for decoded output size.
Pattern coverage
#14 Stack for nested structure
139

LeetCode 735·03 Stacks and monotonic structures·Stacks and parsing

Reveal learning notes #14
What this teaches
Resolve repeated adjacent interactions only when directions actually permit a collision.
Target approach
Stack of surviving asteroids; repeatedly resolve an incoming left-moving asteroid against positive stack tops.
Pattern coverage
#14 Stack for nested structure
140

LeetCode 1094·04 Binary search and intervals·Difference arrays

Reveal learning notes #09, #18
What this teaches
Model capacity with signed pickup/drop-off events and correct endpoint semantics.
Target approach
Use a coordinate difference array or sorted aggregated events; passengers leaving at a point release capacity there.
Pattern coverage
#09 Difference array; #18 Sweep line and events
141

LeetCode 153·04 Binary search and intervals·Binary search

Reveal learning notes #15
What this teaches
Define a monotone comparison against a stable array endpoint to locate a rotation boundary.
Target approach
Find the first element at most the final value, using unique values and explicit handling of an unrotated array.
Pattern coverage
#15 Binary search for a boundary
143

LeetCode 240·04 Binary search and intervals·Matrix search

Reveal learning notes Additional foundation
What this teaches
Distinguish row-and-column monotonicity from the stronger global ordering required by flattening.
Target approach
Staircase elimination from a corner; prove an entire row or column can be discarded.
Pattern coverage
A supporting interview technique outside the 72-pattern index.
144

LeetCode 162·04 Binary search and intervals·Binary search variants

Reveal learning notes Additional foundation
What this teaches
Use a guaranteed peak in the retained half even though the local slope predicate is not globally monotone.
Target approach
Slope-guided interval halving with a peak-existence invariant; do not claim ordinary first-true monotonicity.
Pattern coverage
A supporting interview technique outside the 72-pattern index.
146

LeetCode 57·04 Binary search and intervals·Intervals

Reveal learning notes #17
What this teaches
Exploit already sorted disjoint ranges to avoid sorting during insertion.
Target approach
Emit intervals before the new range, merge overlaps, then append the untouched suffix.
Pattern coverage
#17 Sort and merge intervals
147

LeetCode 986·04 Binary search and intervals·Intervals

Reveal learning notes #17
What this teaches
Combine two ordered disjoint interval streams and discard the one that ends first.
Target approach
Compute max(start) and min(end) intersections; advance the smaller end.
Pattern coverage
#17 Sort and merge intervals
148

LeetCode 142·05 Linked lists and data-structure design·Linked lists

Reveal learning notes #23
What this teaches
Derive the cycle entry from the first meeting point instead of stopping at detection.
Target approach
After a Floyd meeting, reset one pointer to the head and advance both one step at a time.
Pattern coverage
#23 Fast-slow pointers
149

LeetCode 287·05 Linked lists and data-structure design·Linked lists

Reveal learning notes #23
What this teaches
Recognize a functional graph hidden inside an array with constrained values.
Target approach
Treat index-to-value as a successor function and locate its cycle entry without modifying the array.
Pattern coverage
#23 Fast-slow pointers
150

LeetCode 92·05 Linked lists and data-structure design·Linked lists

Reveal learning notes #24
What this teaches
Reconnect a reversed subrange to both outside neighbors, including a range beginning at the head.
Target approach
Dummy predecessor plus bounded in-place reversal; preserve the original subrange head as its new tail.
Pattern coverage
#24 Linked-list reversal
151

LeetCode 234·05 Linked lists and data-structure design·Linked lists

Reveal learning notes #23, #24
What this teaches
Compare symmetric list positions using constant extra space and restore any temporary mutation.
Target approach
Find the midpoint, reverse one half, compare, then restore the reversed links.
Pattern coverage
#23 Fast-slow pointers; #24 Linked-list reversal
152

LeetCode 160·05 Linked lists and data-structure design·Linked-list fundamentals

Reveal learning notes Additional foundation
What this teaches
Equalize total traversal distance without comparing node values or altering either list.
Target approach
Redirect each pointer to the other head after its own tail; stop at shared identity or simultaneous null.
Pattern coverage
A supporting interview technique outside the 72-pattern index.
153

LeetCode 138·05 Linked lists and data-structure design·Linked-list fundamentals

Reveal learning notes #01
What this teaches
Clone a structure with cross-links while preserving aliasing relationships.
Target approach
Map original nodes to clones in two passes; explain the interleaving alternative and its mutation requirement.
Pattern coverage
#01 Hash lookup and frequency
Build on
Two Sum
154

LeetCode 381·05 Linked lists and data-structure design·Data structure design

Reveal learning notes #71
What this teaches
Duplicate values turn the position map into a set of positions, making swap bookkeeping more delicate.
Target approach
Combine an array with value-to-index-set mappings and repair both moved and removed memberships during swap-and-pop.
Pattern coverage
#71 Composite structures for operation guarantees
155

LeetCode 460·05 Linked lists and data-structure design·Data structure design

Reveal learning notes #71
What this teaches
Least frequency plus recency tie-breaking requires maintaining both frequency buckets and order within each bucket.
Target approach
Use key-to-node lookup, a doubly linked recency list per frequency, and a tracked minimum frequency for expected O(1) operations.
Pattern coverage
#71 Composite structures for operation guarantees
Build on
LRU Cache
156

LeetCode 528·05 Linked lists and data-structure design·Randomized design

Reveal learning notes #07, #15
What this teaches
Translate probabilities into disjoint cumulative-weight intervals and avoid boundary bias.
Target approach
Positive prefix weights plus a uniform integer draw and lower_bound; justify each index's probability.
Pattern coverage
#07 Prefix aggregates; #15 Binary search for a boundary
157

LeetCode 341·05 Linked lists and data-structure design·Design fundamentals

Reveal learning notes #14, #71
What this teaches
Preserve traversal state between API calls and distinguish eager preprocessing from lazy iteration.
Target approach
Explicit iterator stack with hasNext advancing to the next integer; explain total versus per-call work.
Pattern coverage
#14 Stack for nested structure; #71 Composite structures for operation guarantees
158

LeetCode 973·06 Heaps and greedy scheduling·Selection and top k

Reveal learning notes #19, #22
What this teaches
Transfer selection to records with a derived priority and no need for a sorted answer.
Target approach
Use squared distance and a size-k max-heap; then implement randomized quickselect over the same key.
Pattern coverage
#19 Heap for top k; #22 Quickselect
160

LeetCode 134·06 Heaps and greedy scheduling·Greedy proofs

Reveal learning notes #50
What this teaches
A failed running-surplus segment rules out every starting point inside that segment.
Target approach
Use total fuel feasibility plus a candidate start reset after negative running surplus; prove the eliminated-start property.
Pattern coverage
#50 Greedy choice with an exchange proof
161

LeetCode 135·06 Heaps and greedy scheduling·Greedy proofs

Reveal learning notes #50
What this teaches
Neighbor constraints run in two directions, so one directional local pass is insufficient.
Target approach
Compute minimum candies satisfying left neighbors, then scan from the right and take the larger requirement at each position.
Pattern coverage
#50 Greedy choice with an exchange proof
162

LeetCode 630·06 Heaps and greedy scheduling·Heap scheduling

Reveal learning notes #50, #51
What this teaches
When a deadline is exceeded, replacing the longest retained course can improve feasibility without reducing the retained count.
Target approach
Sort by deadline, accumulate durations in a max-heap, and remove the longest course whenever the running time exceeds the current deadline.
Pattern coverage
#50 Greedy choice with an exchange proof; #51 Greedy scheduling with a heap
163

LeetCode 2402·06 Heaps and greedy scheduling·Heap scheduling

Reveal learning notes #51
What this teaches
Deterministic resource IDs and delayed jobs require two priorities and careful tie handling.
Target approach
Sort meetings, release all rooms available by the next start into a min-ID heap, and otherwise delay into the earliest (end time, room ID) from a busy heap.
Pattern coverage
#51 Greedy scheduling with a heap
164

LeetCode 101·07 Trees and BSTs·Tree foundations

Reveal learning notes #25
What this teaches
A mirrored relationship changes which child pairs must be compared.
Target approach
Paired traversal comparing left with right and right with left.
Pattern coverage
#25 DFS / flood fill
Build on
Same Tree
166

LeetCode 834·07 Trees and BSTs·Tree DP

Reveal learning notes #36, #66
What this teaches
Move the root across an edge by subtracting one subtree contribution and adding the complement. Moving a root across an edge makes one subtree closer and all other nodes farther.
Target approach
Two-pass rerooting DP with subtree sizes and distance sums. Additional focus: Compute subtree sizes and one distance sum, then propagate answer[child] = answer[parent] + n - 2 * subtreeSize[child].
Pattern coverage
#36 Tree postorder DP; #66 Rerooting tree DP
168

LeetCode 450·07 Trees and BSTs·BSTs

Reveal learning notes #37
What this teaches
Deleting a two-child node requires a replacement whose removal preserves ordering.
Target approach
BST search followed by leaf, one-child, or successor/predecessor replacement cases.
Pattern coverage
#37 BST ordering / inorder traversal
170

LeetCode 437·07 Trees and BSTs·Tree prefix sums

Reveal learning notes #08, #25
What this teaches
Keep prefix counts local to the current root-to-node path; undo them when returning from a branch.
Target approach
DFS with a prefix-frequency map and rollback; explain why prefixes from sibling branches must not mix.
Pattern coverage
#08 Prefix sum plus hash map; #25 DFS / flood fill
171

LeetCode 542·08 Graphs and shortest paths·Shortest paths

Reveal learning notes #26
What this teaches
Transform many nearest-target searches into one nearest-source distance computation.
Target approach
Multi-source BFS from all zero cells.
Pattern coverage
#26 BFS / multi-source BFS
172

LeetCode 1293·08 Graphs and shortest paths·Shortest paths

Reveal learning notes #26, #67
What this teaches
A location reached with different remaining resources represents different future options. The same cell reached with a different obstacle-removal budget may represent a different useful future.
Target approach
BFS over (row, column, remaining eliminations); justify any dominance pruning. Additional focus: Run BFS on (row, column, eliminationsRemaining); if compressing visited state, justify dominance using nondecreasing BFS distance.
Pattern coverage
#26 BFS / multi-source BFS; #67 Expanded-state graph search
173

LeetCode 1631·08 Graphs and shortest paths·Weighted graphs

Reveal learning notes #28
What this teaches
The cost of a route can aggregate with maximum instead of sum.
Target approach
Dijkstra using candidate = max(current effort, edge effort); justify monotonicity.
Pattern coverage
#28 Dijkstra's shortest paths
174

LeetCode 1514·08 Graphs and shortest paths·Weighted graphs

Reveal learning notes #28
What this teaches
The same finalization argument works for decreasing probability products with a max-heap.
Target approach
Maximum-probability Dijkstra with multiplicative relaxation.
Pattern coverage
#28 Dijkstra's shortest paths
175

LeetCode 399·08 Graphs and shortest paths·Connectivity

Reveal learning notes #25, #32
What this teaches
Ratios are edge relations and a weighted DSU must preserve each node-to-parent potential.
Target approach
First solve by graph DFS; then implement weighted DSU and derive its union ratio.
Pattern coverage
#25 DFS / flood fill; #32 Union–find / disjoint-set union
176

LeetCode 802·08 Graphs and shortest paths·Dependencies

Reveal learning notes #31, #35, #68
What this teaches
A vertex is unsafe if any reachable route can remain in a directed cycle. Nodes safe from all cycles can be removed backward starting at terminal nodes.
Target approach
Reverse-graph outdegree elimination; also explain DFS active and resolved states. Additional focus: Reverse directed edges, maintain original outdegrees, and repeatedly remove zero-outdegree nodes; report all nodes removed.
Pattern coverage
#31 Topological ordering / DAG DP; #35 DFS cycle states / strongly connected components; #68 Reverse reasoning / reverse graph
177

LeetCode 90·09 Backtracking and tries·Backtracking

Reveal learning notes #49
What this teaches
Equal values must be skipped at the same recursion depth without suppressing legitimate repeated values at deeper levels.
Target approach
Sort and use depth-local duplicate skipping in increasing-index subset DFS.
Pattern coverage
#49 Backtracking and pruning
Build on
Subsets
178

LeetCode 47·09 Backtracking and tries·Backtracking

Reveal learning notes #49
What this teaches
Duplicate permutations require controlling which identical unused copy may be chosen next.
Target approach
Use sorted values plus a used array with a same-value predecessor rule, or recurse on value frequencies.
Pattern coverage
#49 Backtracking and pruning
179

LeetCode 40·09 Backtracking and tries·Backtracking

Reveal learning notes #49
What this teaches
Combining one-use candidates with duplicate values requires both advancing the index and suppressing equivalent sibling branches.
Target approach
Sort, recurse from index + 1 after choosing a candidate, skip equal values at one depth, and prune positive candidates above the remaining target.
Pattern coverage
#49 Backtracking and pruning
180

LeetCode 51·09 Backtracking and tries·Backtracking

Reveal learning notes #49
What this teaches
A valid placement can be tested from occupied columns and diagonals rather than rescanning the board.
Target approach
Place one queen per row and maintain column, row-column, and row+column occupancy sets or masks.
Pattern coverage
#49 Backtracking and pruning
181

LeetCode 131·09 Backtracking and tries·Backtracking

Reveal learning notes #49, #56
What this teaches
A partition search becomes cheaper when validity of each candidate substring is precomputed.
Target approach
Build a palindrome interval DP table, then enumerate cut positions with DFS using that table.
Pattern coverage
#49 Backtracking and pruning; #56 Palindrome centers / palindrome DP
182

LeetCode 140·09 Backtracking and tries·Backtracking

Reveal learning notes #49
What this teaches
Enumerating all valid segmentations requires retaining every valid continuation rather than only a boolean reachability result.
Target approach
Build or memoize valid suffix segmentations by start index, optionally prune unreachable suffixes, and account for total output length.
Pattern coverage
#49 Backtracking and pruning
183

LeetCode 1755·09 Backtracking and tries·Meet in the middle

Reveal learning notes #52
What this teaches
About forty signed choices favor half-subset enumeration; positive-only pruning is unavailable.
Target approach
Enumerate both halves, sort one half, and binary search the nearest complement for every sum in the other half.
Pattern coverage
#52 Meet in the middle
184

LeetCode 212·09 Backtracking and tries·Tries

Reveal learning notes #49, #53
What this teaches
Searching a board for many words can share dictionary prefixes instead of repeating a full search for every word.
Target approach
Build a trie and DFS from each board cell with visited-cell restoration; suppress duplicate emitted words and optionally prune exhausted trie branches.
Pattern coverage
#49 Backtracking and pruning; #53 Trie / prefix tree
185

LeetCode 1268·09 Backtracking and tries·Tries

Reveal learning notes #53
What this teaches
A small requested output per prefix can be cached in trie nodes during construction.
Target approach
Use a trie with the lexicographically smallest three suggestions per node; also explain the sorted-array lower-bound alternative.
Pattern coverage
#53 Trie / prefix tree
186

LeetCode 421·09 Backtracking and tries·Bits

Reveal learning notes #53, #57
What this teaches
The largest XOR is chosen from the most significant bit downward, where a higher differing bit dominates all lower bits.
Target approach
Build a binary trie and greedily query opposite bits from most to least significant; use the problem input width.
Pattern coverage
#53 Trie / prefix tree; #57 XOR, bit masks, and bit counts
187

LeetCode 864·10 Dynamic programming·Shortest paths

Reveal learning notes #26, #46, #57, #67
What this teaches
Include the collected-key mask in visited state because possession changes legal moves. Returning to a cell with a new key set can unlock transitions that were previously impossible.
Target approach
BFS over (row, column, key mask), updating the mask before the visited check. Additional focus: Run BFS on (row, column, collectedKeysMask) and mark the entire state visited.
Pattern coverage
#26 BFS / multi-source BFS; #46 Bitmask DP; #57 XOR, bit masks, and bit counts; #67 Expanded-state graph search
188

LeetCode 213·10 Dynamic programming·DP foundations

Reveal learning notes #39, #48
What this teaches
A cyclic dependency can be removed by conditioning on mutually exclusive endpoints.
Target approach
Reduce to two linear robber ranges with small-input handling.
Pattern coverage
#39 Memoization / one-dimensional DP; #48 Finite-state DP: stock / cooldown
Build on
House Robber
189

LeetCode 63·10 Dynamic programming·Grid DP

Reveal learning notes #40
What this teaches
An obstacle must reset a compressed state so paths cannot leak through blocked cells.
Target approach
One-row path-count DP with blocked-cell and boundary initialization.
Pattern coverage
#40 Grid DP
Build on
Unique Paths
190

LeetCode 174·10 Dynamic programming·Grid DP

Reveal learning notes #40
What this teaches
Work backward with required entering health because cumulative path sum loses the minimum-prefix constraint.
Target approach
Reverse grid DP with minimum required health clamped to one.
Pattern coverage
#40 Grid DP
191

LeetCode 1463·10 Dynamic programming·Grid DP

Reveal learning notes #40
What this teaches
Synchronized agents share one time or row index but require separate positions, and overlapping rewards must be counted once.
Target approach
DP over (row, first column, second column), considering both robots’ moves together and rolling the row dimension.
Pattern coverage
#40 Grid DP
192

LeetCode 474·10 Dynamic programming·Knapsack

Reveal learning notes #41
What this teaches
Two independent resource budgets require two capacity dimensions and descending updates in both.
Target approach
Two-capacity 0/1 knapsack maximizing the number of chosen strings.
Pattern coverage
#41 0/1 knapsack / subset sum
193

LeetCode 377·10 Dynamic programming·Knapsack

Reveal learning notes #42
What this teaches
Changing the loop order counts ordered constructions instead of unordered combinations.
Target approach
Amount-first counting DP with each number treated as the final choice.
Pattern coverage
#42 Unbounded knapsack / coin change
194

LeetCode 115·10 Dynamic programming·Sequence DP

Reveal learning notes #43
What this teaches
Counting embeddings requires adding alternatives even when a match is possible.
Target approach
Two-sequence count DP; if compressed, update the target index backward.
Pattern coverage
#43 Two-sequence DP: LCS / edit distance
195

LeetCode 97·10 Dynamic programming·Sequence DP

Reveal learning notes #43
What this teaches
Two consumed-prefix lengths determine the third position, so a third state dimension is redundant.
Target approach
Boolean two-sequence DP with target index i + j and a length precheck.
Pattern coverage
#43 Two-sequence DP: LCS / edit distance
196

LeetCode 10·10 Dynamic programming·Sequence DP

Reveal learning notes #43
What this teaches
A repetition operator branches between skipping its token and consuming another matching character.
Target approach
Memoized text-pattern indices or equivalent DP supporting only the specified dot and star rules.
Pattern coverage
#43 Two-sequence DP: LCS / edit distance
197

LeetCode 354·10 Dynamic programming·Sequence DP

Reveal learning notes #44
What this teaches
Sorting one dimension needs a reversed tie order to prevent illegal equality in the remaining LIS.
Target approach
Sort widths ascending and tied heights descending, then strict height LIS.
Pattern coverage
#44 Longest increasing subsequence: tails
200

LeetCode 1547·10 Dynamic programming·Interval DP

Reveal learning notes #45
What this teaches
Choosing a cut splits an interval into independent pieces with a shared boundary-dependent cost.
Target approach
Sorted-cut interval DP with stick endpoints inserted as sentinels.
Pattern coverage
#45 Interval DP
204

LeetCode 214·11 Strings, bits and mathematics·Exact string matching

Reveal learning notes #54
What this teaches
Prepending the fewest characters reduces to finding the longest palindromic prefix.
Target approach
Use the prefix function on s + an out-of-alphabet separator + reverse(s), then prepend the reverse of the unmatched suffix.
Pattern coverage
#54 KMP / Z-function matching
205

LeetCode 260·11 Strings, bits and mathematics·Bits

Reveal learning notes #57
What this teaches
Two unique values can be separated by one bit on which they differ.
Target approach
XOR all values, isolate one set bit, partition values by that bit, and XOR within each partition.
Pattern coverage
#57 XOR, bit masks, and bit counts
206

LeetCode 137·11 Strings, bits and mathematics·Bits

Reveal learning notes #57
What this teaches
Triplicate cancellation requires counts modulo three at each bit position instead of ordinary XOR.
Target approach
Count each fixed-width bit modulo three and reconstruct the signed answer correctly.
Pattern coverage
#57 XOR, bit masks, and bit counts
207

CSES 1095·11 Strings, bits and mathematics·Arithmetic

Reveal learning notes #58
What this teaches
A huge exponent is manageable when repeated squaring composes identical multiplication steps.
Target approach
Implement modular binary exponentiation, handle exponent zero, and use multiplication wide enough for the given modulus.
Pattern coverage
#58 GCD and modular arithmetic
208

LeetCode 204·11 Strings, bits and mathematics·Arithmetic

Reveal learning notes #59
What this teaches
Testing every candidate by trial division wastes work when all candidates share one upper bound.
Target approach
Implement the sieve of Eratosthenes, mark from p*p, and treat the bound as exclusive.
Pattern coverage
#59 Sieve and divisor preprocessing
209

LeetCode 315·12 Advanced queries and reductions·Range structures

Reveal learning notes #60, #63
What this teaches
Scanning from the right turns later-smaller counting into prefix frequency queries over compressed values.
Target approach
Coordinate-compress unique values and use a Fenwick frequency tree; query ranks strictly below the current rank before inserting it.
Pattern coverage
#60 Fenwick tree / binary indexed tree; #63 Coordinate compression
210

LeetCode 1697·12 Advanced queries and reductions·Offline queries

Reveal learning notes #64
What this teaches
Sorting queries by an edge-weight limit turns each answer into connectivity among currently activated edges.
Target approach
Sort edges and indexed queries by threshold, add only edges with weight strictly below each threshold to DSU, and restore original query order.
Pattern coverage
#64 Offline query ordering
211

LeetCode 327·01 Arrays, hashing and sorting·Merge counting

Reveal learning notes #70
What this teaches
A range-sum condition becomes a bounded difference between prefix sums while their original index order remains essential.
Target approach
Form prefix sums and use merge-sort counting with two monotone pointers to count right-half values in each left prefix sum plus [lower, upper].
Pattern coverage
#70 Merge-sort counting / divide and conquer
212

LeetCode 862·03 Stacks and monotonic structures·Monotonic deques

Reveal learning notes #07, #13
What this teaches
Recover shortest qualifying subarrays with negatives by dominating prefix candidates instead of using an ordinary sum window.
Target approach
Increasing deque of prefix sums; pop feasible starts from front and dominated starts from back.
Pattern coverage
#07 Prefix aggregates; #13 Monotonic deque
213

LeetCode 224·03 Stacks and monotonic structures·Stacks and parsing

Reveal learning notes #14
What this teaches
Handle signs, nested parentheses, and unary minus without assuming every minus has two operands.
Target approach
Sign/context stack or explicit nested parser; evaluate according to the problem's actual operator set.
Pattern coverage
#14 Stack for nested structure
214

LeetCode 4·04 Binary search and intervals·Binary search

Reveal learning notes #15
What this teaches
Search partition positions rather than values while preserving the number of elements in the lower half.
Target approach
Binary search a partition of the shorter array; enforce both cross-boundary ordering inequalities.
Pattern coverage
#15 Binary search for a boundary
215

LeetCode 719·04 Binary search and intervals·Binary search on answers

Reveal learning notes #05, #16
What this teaches
Find a rank in an implicit quadratic multiset by counting how many values fall below a candidate.
Target approach
Sort; binary search distance; count pairs within that distance using two moving boundaries.
Pattern coverage
#05 Variable-size sliding window; #16 Binary search on the answer
217

LeetCode 25·05 Linked lists and data-structure design·Linked lists

Reveal learning notes #24
What this teaches
Check a complete group exists before committing a local structural transformation.
Target approach
Locate the kth node, reverse exactly k links, reconnect groups, and leave a short suffix unchanged.
Pattern coverage
#24 Linked-list reversal
218

LeetCode 432·05 Linked lists and data-structure design·Data structure design

Reveal learning notes #71
What this teaches
Increment/decrement by one enables adjacent frequency buckets and constant-time minimum/maximum access.
Target approach
Use a doubly linked ordered list of count buckets with key sets and a key-to-bucket map; create and delete neighboring buckets as necessary.
Pattern coverage
#71 Composite structures for operation guarantees
Build on
LFU Cache
219

LeetCode 632·06 Heaps and greedy scheduling·K-way merging

Reveal learning notes #20
What this teaches
Maintain coverage of every source while minimizing the span between the smallest and largest exposed values.
Target approach
Heap of one current value per list plus a running maximum; advance the minimum source until one list ends.
Pattern coverage
#20 Heap for k-way merge
220

LeetCode 480·06 Heaps and greedy scheduling·Streaming median

Reveal learning notes #21
What this teaches
Support window expirations without confusing physical heap size with the number of live elements.
Target approach
Dual heaps with delayed deletion, logical sizes, and root pruning; periodically rebuild to bound stale storage, or explicitly document unbounded lazy-heap growth.
Pattern coverage
#21 Two heaps for a median
222

CSES 1135·07 Trees and BSTs·Tree ancestors

Reveal learning notes #38
What this teaches
Two root distances and a lowest common ancestor determine an arbitrary tree path length.
Target approach
Binary lifting LCA plus depth[a] + depth[b] − 2 × depth[lca].
Pattern coverage
#38 LCA / binary lifting
223

LeetCode 1044·07 Trees and BSTs·Substring hashing

Reveal learning notes #55
What this teaches
Repeated-substring length is monotone, but a hash match is only a candidate equality.
Target approach
Binary search the length and use rolling hashes to group candidates; verify actual substring equality within hash buckets, including collisions, and discuss verification worst cases.
Pattern coverage
#55 Rolling hash for substring queries
224

CSES 1137·07 Trees and BSTs·Tree reductions

Reveal learning notes #60, #65
What this teaches
A subtree becomes a contiguous interval in entry-only DFS order.
Target approach
Compute tin/tout intervals, place node values in Euler-entry order, and use Fenwick point deltas plus subtree interval sums.
Pattern coverage
#60 Fenwick tree / binary indexed tree; #65 Euler tour tree flattening
225

CSES 1132·07 Trees and BSTs·Tree reductions

Reveal learning notes #66
What this teaches
Farthest-distance answers need a way to exclude the child branch when propagating an outside contribution.
Target approach
Use two-pass rerooting DP with downward best distances and the best two child contributions; do not use diameter endpoints for this exercise.
Pattern coverage
#66 Rerooting tree DP
227

CSES 1197·08 Graphs and shortest paths·Weighted graphs

Reveal learning notes #29
What this teaches
Detect a negative cycle anywhere and recover a concrete cycle from predecessor links.
Target approach
Bellman–Ford with a virtual super-source or all-zero initial distances, followed by predecessor walking.
Pattern coverage
#29 Bellman–Ford
230

LeetCode 1489·08 Graphs and shortest paths·Connectivity

Reveal learning notes #32, #33
What this teaches
Determine whether an edge is forced, optional, or excluded across optimal spanning trees.
Target approach
Repeated Kruskal runs excluding and forcing each edge, preserving original edge identities.
Pattern coverage
#32 Union–find / disjoint-set union; #33 Minimum spanning tree
231

CSES 1683·08 Graphs and shortest paths·Dependencies

Reveal learning notes #35
What this teaches
Mutual reachability requires strongly connected components rather than ordinary DFS components.
Target approach
Kosaraju or Tarjan SCC decomposition, and explain why component contraction is acyclic.
Pattern coverage
#35 DFS cycle states / strongly connected components
232

LeetCode 803·08 Graphs and shortest paths·Reverse reasoning

Reveal learning notes #68
What this teaches
Deletion is difficult for ordinary DSU, but reversing all hits converts the process into additions.
Target approach
Apply hits, build DSU on remaining bricks with a virtual roof, then restore valid hits backward and measure the roof-component growth minus the restored brick. Report max(0, newRoofSize - oldRoofSize - 1) after a real restoration; originally empty hits report zero.
Pattern coverage
#68 Reverse reasoning / reverse graph
233

LeetCode 1192·08 Graphs and shortest paths·Extra: low-link bridges

Reveal learning notes Additional foundation
What this teaches
A tree edge is a bridge exactly when its child subtree cannot reach the parent or an ancestor through another edge.
Target approach
Implement DFS discovery times and low-link values; identify bridges using low[child] > discovery[parent] and track parent edges carefully.
Pattern coverage
A supporting interview technique outside the 72-pattern index.
234

LeetCode 332·08 Graphs and shortest paths·Extra: Euler trails

Reveal learning notes Additional foundation
What this teaches
Using every ticket exactly once is an edge-visitation problem; ordinary vertex DFS does not model the objective.
Target approach
Use Hierholzer traversal from JFK with lexicographically ordered outgoing edges and reverse the postorder route; account for duplicate tickets.
Pattern coverage
A supporting interview technique outside the 72-pattern index.
235

CSES 1195·08 Graphs and shortest paths·Weighted state graphs

Reveal learning notes #28, #67
What this teaches
Combine unequal edge weights with a one-use resource that changes future costs.
Target approach
Require Dijkstra on (city,discountUsed), with a transition costing floor(edgeWeight/2) when consuming the discount. Compare with two shortest-path passes as a second solution.
Pattern coverage
#28 Dijkstra's shortest paths; #67 Expanded-state graph search
236

LeetCode 37·09 Backtracking and tries·Constraint search

Reveal learning notes #49, #57
What this teaches
Constraint propagation and choosing the most restricted variable can shrink an otherwise enormous assignment search.
Target approach
Maintain row/column/box masks, choose an empty cell with fewest legal digits, and undo every placement on backtracking.
Pattern coverage
#49 Backtracking and pruning; #57 XOR, bit masks, and bit counts
Build on
N-Queens
237

LeetCode 2035·09 Backtracking and tries·Meet in the middle

Reveal learning notes #52
What this teaches
An exact chosen-element count requires grouping half sums by cardinality before joining them.
Target approach
Enumerate each half into buckets by selected count, then combine complementary counts with sorting and nearest-complement search.
Pattern coverage
#52 Meet in the middle
238

CSES 1628·09 Backtracking and tries·Meet in the middle

Reveal learning notes #52
What this teaches
Counting subsets needs multiplicities of equal half sums, which nearest-sum optimization may ignore.
Target approach
Enumerate half sums and count all complementary sum pairs using frequency maps or sorted runs; keep duplicate sums.
Pattern coverage
#52 Meet in the middle
239

LeetCode 464·10 Dynamic programming·Subset DP

Reveal learning notes #46
What this teaches
Histories with the same used-number set have the same remaining total and winning options.
Target approach
Memoized winning-state bitmask DP with immediate-win and total-sum feasibility checks.
Pattern coverage
#46 Bitmask DP
241

LeetCode 847·10 Dynamic programming·Subset DP

Reveal learning notes #26, #46, #57, #67
What this teaches
A visit-all route needs both a collected subset and a current endpoint, and may revisit nodes. The set of visited vertices belongs in the state when completion requires visiting every node.
Target approach
Multi-source BFS over (node, visited mask); contrast with acyclic Hamiltonian subset DP. Additional focus: Run multi-source BFS from every (startNode, singletonMask) and stop at the full visited mask.
Pattern coverage
#26 BFS / multi-source BFS; #46 Bitmask DP; #57 XOR, bit masks, and bit counts; #67 Expanded-state graph search
242

CSES 1690·10 Dynamic programming·Subset DP

Reveal learning notes #46
What this teaches
A subset alone cannot identify which incoming edges can extend a partial route.
Target approach
Counting DP over (visited mask, last vertex), with start/end restrictions and multiplicities.
Pattern coverage
#46 Bitmask DP
244

CSES 1722·10 Dynamic programming·Transition exponentiation

Reveal learning notes #58, #69
What this teaches
A constant-size linear recurrence can jump across an enormous index by composing its transition matrix.
Target approach
Implement 2-by-2 matrix exponentiation modulo the specified modulus, derive the initial vector, and test indices zero and one.
Pattern coverage
#58 GCD and modular arithmetic; #69 Matrix / transition exponentiation
245

CSES 1723·10 Dynamic programming·Transition exponentiation

Reveal learning notes #58, #69
What this teaches
Exactly-k-step walk counts are entries of an adjacency matrix power, including contributions from parallel edges.
Target approach
Use adjacency-matrix exponentiation over modular sum/product arithmetic and read the required source-to-target entry.
Pattern coverage
#58 GCD and modular arithmetic; #69 Matrix / transition exponentiation
246

CSES 1753·11 Strings, bits and mathematics·Exact string matching

Reveal learning notes #54
What this teaches
Counting all occurrences must preserve overlaps after a complete match.
Target approach
Implement Z-function matching on pattern + a separator outside the alphabet + text, and count all positions with Z at least the pattern length.
Pattern coverage
#54 KMP / Z-function matching
247

CSES 1079·11 Strings, bits and mathematics·Arithmetic

Reveal learning notes #58
What this teaches
Many binomial queries under a prime modulus benefit from factorial and inverse-factorial preprocessing.
Target approach
Precompute factorials and modular inverse factorials using Fermat exponentiation; explain why the prime modulus and argument bounds permit these inverses.
Pattern coverage
#58 GCD and modular arithmetic
248

CSES 1713·11 Strings, bits and mathematics·Arithmetic

Reveal learning notes #59
What this teaches
Repeated bounded divisor queries can share factorization work.
Target approach
Precompute smallest prime factors up to the maximum input, factor each query, and multiply one plus each prime exponent.
Pattern coverage
#59 Sieve and divisor preprocessing
Build on
Count Primes
249

CSES 1749·12 Advanced queries and reductions·Range structures

Reveal learning notes #60
What this teaches
Removing the kth live position is an order-statistic query on nonnegative frequencies.
Target approach
Initialize a Fenwick tree of ones, locate the kth live element by Fenwick binary lifting, then subtract its frequency.
Pattern coverage
#60 Fenwick tree / binary indexed tree
250

CSES 1649·12 Advanced queries and reductions·Range structures

Reveal learning notes #61
What this teaches
Arbitrary point replacement and range minimum need an associative aggregate rather than prefix subtraction.
Target approach
Build a segment tree storing minimum with an infinity identity and support point assignments and interval queries.
Pattern coverage
#61 Segment tree / lazy propagation
251

CSES 1735·12 Advanced queries and reductions·Range structures

Reveal learning notes #61
What this teaches
Range assignment and addition tags compose in different orders, so a single undifferentiated pending value is insufficient.
Target approach
Implement a lazy segment tree for sums with segment length, an explicit pending-assignment flag/value, and pending addition; derive tag composition in chronological order.
Pattern coverage
#61 Segment tree / lazy propagation
252

CSES 1143·12 Advanced queries and reductions·Range structures

Reveal learning notes #61
What this teaches
Finding the first feasible index can descend a maximum segment tree rather than binary-searching with repeated queries.
Target approach
Store segment maxima, descend left first whenever its maximum can satisfy the request, and decrement the selected leaf.
Pattern coverage
#61 Segment tree / lazy propagation
253

CSES 1647·12 Advanced queries and reductions·Range structures

Reveal learning notes #62
What this teaches
Static idempotent minimum queries permit overlapping precomputed blocks, while sum would double-count the overlap.
Target approach
Implement a sparse table and O(1) minimum queries using two covering power-of-two blocks; do not substitute a segment tree.
Pattern coverage
#62 Sparse table for static idempotent queries
254

CSES 1144·12 Advanced queries and reductions·Range structures

Reveal learning notes #60, #63
What this teaches
Offline-known replacement values can all be compressed before processing dynamic frequency queries.
Target approach
Collect initial and update salaries for coordinate compression, then use Fenwick point-frequency changes and lower/upper bounds for inclusive value-range counts.
Pattern coverage
#60 Fenwick tree / binary indexed tree; #63 Coordinate compression
255

CSES 1734·12 Advanced queries and reductions·Offline queries

Reveal learning notes #64
What this teaches
Ordering static queries by right endpoint lets one active marker per value represent distinctness in any queried suffix.
Target approach
Sort queries by right endpoint, move each value's Fenwick marker from its previous occurrence to its latest, and query interval sums; separately derive and compare Mo's add/remove alternative.
Pattern coverage
#64 Offline query ordering
256

CSES 1696·12 Advanced queries and reductions·Matching and flow

Reveal learning notes #72
What this teaches
A currently occupied partner may be reassigned along an augmenting path to increase the total matching.
Target approach
Implement augmenting-path bipartite matching and output the matched pairs; state its O(VE) bound and when Hopcroft-Karp is preferable.
Pattern coverage
#72 Matching / flow reduction
257

CSES 1694·12 Advanced queries and reductions·Matching and flow

Reveal learning notes #72
What this teaches
Multiple units of capacity require a residual network with reverse edges instead of one irreversible greedy path choice.
Target approach
Implement Dinic with residual capacities, level-graph BFS and blocking-flow DFS; use wide integers and handle parallel edges.
Pattern coverage
#72 Matching / flow reduction
Build on
School Dance

The 72-pattern coverage index

Open a pattern to find every assigned problem.

A problem can cover several patterns when the learning notes explicitly require them. Supporting fundamentals may have no pattern number. Follow a problem link to clear filters and jump to its curriculum entry.

01Hash lookup and frequency15
02Opposite-end two pointers4
03Read-write pointers4
04Fixed-size sliding window2
05Variable-size sliding window9
06Exactly k via at-most counts2
07Prefix aggregates4
08Prefix sum plus hash map4
09Difference array2
10Kadane's maximum subarray2
11Prefix-suffix composition2
12Monotonic stack4
13Monotonic deque3
14Stack for nested structure7
15Binary search for a boundary8
16Binary search on the answer4
17Sort and merge intervals3
18Sweep line and events3
19Heap for top k4
20Heap for k-way merge3
21Two heaps for a median2
22Quickselect2
23Fast-slow pointers5
24Linked-list reversal5
25DFS / flood fill12
26BFS / multi-source BFS8
270–1 BFS1
28Dijkstra's shortest paths4
29Bellman–Ford2
30Floyd–Warshall1
31Topological ordering / DAG DP5
32Union–find / disjoint-set union5
33Minimum spanning tree2
34Bipartite coloring1
35DFS cycle states / strongly connected components3
36Tree postorder DP6
37BST ordering / inorder traversal5
38LCA / binary lifting4
39Memoization / one-dimensional DP8
40Grid DP6
410/1 knapsack / subset sum3
42Unbounded knapsack / coin change3
43Two-sequence DP: LCS / edit distance5
44Longest increasing subsequence: tails3
45Interval DP3
46Bitmask DP5
47Digit DP1
48Finite-state DP: stock / cooldown7
49Backtracking and pruning13
50Greedy choice with an exchange proof7
51Greedy scheduling with a heap4
52Meet in the middle3
53Trie / prefix tree5
54KMP / Z-function matching4
55Rolling hash for substring queries1
56Palindrome centers / palindrome DP3
57XOR, bit masks, and bit counts10
58GCD and modular arithmetic5
59Sieve and divisor preprocessing2
60Fenwick tree / binary indexed tree5
61Segment tree / lazy propagation3
62Sparse table for static idempotent queries1
63Coordinate compression2
64Offline query ordering2
65Euler tour tree flattening1
66Rerooting tree DP2
67Expanded-state graph search4
68Reverse reasoning / reverse graph3
69Matrix / transition exponentiation2
70Merge-sort counting / divide and conquer3
71Composite structures for operation guarantees8
72Matching / flow reduction2

Can you recognize it without the label?

These checkpoints are intentionally shown as a mixed, title-only list. Reserve them until the relevant foundations are familiar. If you already saw a solution or its learning note, use a fresh related problem for your next blind assessment.

  1. Cheapest Flights Within K Stops (official problem, opens in a new tab)
  2. Koko Eating Bananas (official problem, opens in a new tab)
  3. Distinct Subsequences (official problem, opens in a new tab)
  4. Random Pick with Weight (official problem, opens in a new tab)
  5. Longest Continuous Subarray With Absolute Diff Less Than or Equal to Limit (official problem, opens in a new tab)
  6. Accounts Merge (official problem, opens in a new tab)
  7. Linked List Cycle II (official problem, opens in a new tab)
  8. Target Sum (official problem, opens in a new tab)
  9. Pacific Atlantic Water Flow (official problem, opens in a new tab)
  10. K Closest Points to Origin (official problem, opens in a new tab)
  11. Partition Labels (official problem, opens in a new tab)

What counts as mastery?

Judge the performance, not the submission count.
01

Independent

From a blank editor, explain a suitable method, justify why it works, implement it without solution help, test it, and meet the required complexity.

02

Retained

Repeat from a blank editor after at least a week without reading your old code. Explain the invariant rather than recalling line order.

03

Transfer

Solve an unfamiliar related problem with its topic label hidden, or handle a changed constraint and justify the new method.

04

Interview-ready evidence

Across several mixed timed sessions, clarify requirements, derive an approach, communicate tradeoffs, write correct code, and debug independently. A completed list alone cannot establish this.

Use a mix of fresh problems and the blind checkpoint set. Aim to complete several 45-60 minute sessions containing one substantial problem or two shorter ones without hints, including explanation and tests. Diagnose repeated gaps by pattern and revisit those modules. The timing is a practice design, not a claim about every employer.

A productive study session
  1. Before coding: identify the output, structure, constraints, brute-force cost, candidate patterns, and the property that permits improvement.
  2. Attempt a Core problem for roughly 25-40 focused minutes before seeking a small hint. Harder Reinforcement or Extension work can take longer; these are study timeboxes, not universal interview limits.
  3. If stuck, name the missing step and reveal the smallest useful hint. Reading a full solution counts as Learning, even when the later submission passes.
  4. After coding: state time and space, test adversarial cases, and record the failed assumption or implementation mistake.
  5. Rebuild on a later day, then revisit after about a week. Adjust intervals to your recall; the tracker uses an editable review interval.
  6. For each technique, change one property: allow negatives, require a witness, add updates, permit duplicate values, or switch from counting to optimization.
How these problems were selected
  • Select an anchor for each method, then a variation that changes a constraint, output, state, or invariant.
  • Keep additional problems only when they teach a distinct implementation or reasoning skill. Count each canonical problem once even if it covers several patterns.
  • Prescribe the learning approach where multiple valid algorithms exist. A judge acceptance using another method does not prove coverage of the assigned pattern.
  • Prefer problems whose statements are available without a paid subscription. Platform access and editorial availability can change independently.
  • Separate specialist extensions from the general interview path. Tier and order are editorial judgments, not measured company-frequency rankings.
Implementation checks
  • Implement lower_bound and upper_bound with explicit interval invariants.
  • Implement an iterative traversal, BFS with path reconstruction, and heap-based Dijkstra with stale-entry handling.
  • Implement DSU with union by size/rank and path compression; explain why DSU parents are not graph paths.
  • Implement and test a heap, trie, linked-list reversal, and an LRU cache using the appropriate primitives.
  • Derive a DP state and recurrence before choosing memoization, tabulation, or space compression.
  • For full specialist coverage, implement a Fenwick tree, lazy segment tree, sparse table, KMP, and one matching algorithm.
Questions that test transfer
Sliding window
What changes if values may be negative, or if the window must contain exactly k distinct values?
Prefix sums
Does the query ask for a count, a longest interval, or a shortest interval? What must each prefix-map entry store?
Binary search
What makes the predicate monotone, what are the bounds, and what happens when no feasible value exists?
Monotonic structures
Why is a removed candidate permanently dominated? Which equality rule and expiration rule are correct?
Graphs
Do weights, direction, cycles, or resources change the search method or the definition of a state?
Trees
Is the answer for one subtree, one path, one root, or every possible root?
Dynamic programming
Which histories may share a state? Does loop order allow reuse or change whether order is counted?
Greedy
What exchange or dominance argument proves the choice safe? What weighted variant breaks it?
Data-structure design
What must be synchronized across structures? Are complexity guarantees expected, amortized, or worst-case?
Strings and ranges
Do queries require exactness, updates, prefix structure, or a particular algebraic property?