Digit DP
Count numbers up to N that satisfy a digit property by building them one digit at a time, with a tight flag that tracks whether the prefix still matches N.
The problem
Count how many integers in have a property that depends on their digits. For example: no two adjacent digits are equal (1213 yes, 1223 no).
The range can reach , so you cannot test each number. Brute force over numbers is far out of reach.
1 of 8