Digit DP (dynamic programming) processes numbers as sequences of digits. To count integers from to , you represent as a string and build valid numbers position by position.
For example, if , you process three positions. At each position, you decide which digit to place, subject to constraints. Some digits might violate your condition (like repeating a digit when you want all distinct).
The observation: instead of iterating over all numbers, you iterate over all ways to fill digit positions. This turns into , which is tiny even for .