At position with tight bound: If tight: you can only place digits . For each allowed digit , recurse with tight = .
If not tight: you can place any allowed digit. Recurse with tight = false. To compute dp(pos, tight), loop through the digit set and checks if each digit is valid given the current tight status. This formula tells you how to compute dp(pos, tight) from dp values at later positions. Getting this right is the core of DP.