Why it matters
Digit DP handles many counting problems.
Advertisement
The architecture
State: position, tight (bound by N), leading zeros, aux.
Transition: try each digit.
Advertisement
How it works end to end
Range [L, R]: count(R) - count(L-1).
Applications: count numbers with digit sum k, digits all different, etc.