Concepts19
State Space Reduction
State space reduction shrinks the number of dynamic programming or search states by keeping only the information that truly affects future decisions.
Matrix Exponentiation
Matrix exponentiation turns repeated linear transitions into a single fast power of a matrix using exponentiation by squaring.
Exchange Arguments in DP
An exchange argument proves that any optimal solution can be reordered to satisfy a simple sorting rule by showing that swapping adjacent out-of-order elements never helps.
Interval DP
Interval DP solves problems where the optimal answer for a segment [i, j] depends on answers of its subsegments.
Tree DP - Rerooting Technique
Rerooting (a.k.a. 换根 DP) computes a per-node answer as if each node were the root, in total O(n) time on trees.
Digit DP
Digit DP is a dynamic programming technique for counting or aggregating values over all integers in a range that satisfy a digit-based property.
Tree DP - Matching and Covering
Tree DP solves matching, vertex cover, and independent set on trees in linear time using small state transitions per node.
Bitmask DP
Bitmask DP compresses the state of a subset of n elements into an integer mask, enabling elegant dynamic programming over all subsets.
Longest Common Subsequence
The Longest Common Subsequence (LCS) between two sequences is the longest sequence that appears in both, not necessarily contiguously.
Bitmask DP - Subset Enumeration
Bitmask DP subset enumeration lets you iterate all submasks of a given mask using the idiom for (s = mask; s > 0; s = (s - 1) & mask).
DP on Trees
DP on trees is a technique that computes answers for each node by combining results from its children using a post-order DFS.
Edit Distance
Edit distance (Levenshtein distance) measures the minimum number of inserts, deletes, and replaces needed to turn one string into another.