Concepts23
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.
Bellman Equations
Bellman equations express how the value of a state or action equals immediate reward plus discounted value of what follows.
Derangements
A derangement is a permutation with no element left in its original position, often written as !n or D(n).
Stars and Bars
Stars and Bars counts the ways to distribute n identical items into k distinct bins using combinations.
Permutations and Combinations
Permutations count ordered selections, while combinations count unordered selections.
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.