Digit DP is a technique used to solve problems that asks you to find the number of integers within a range that satisfies some property based on the digits of the integers.
Typically, the ranges are between large integers (such as between 1 and 1018), so looping through each integer and checking if it satisfies the given property is too slow.
Digit DP uses the digits of the integers to quickly count the number of integers with the given property in the range of integers.
Implementation
Below is the example to count the total number of digit 1 appearing in all integers from the range of low to high.
The DP state will be dp(index, tight, count).
Note
Depends on the problems, sometimes the variables such as isLeading, isZero will need to be included in the DP state.