Shorter numbers need separate handling. Count them with simple math: for each length .
Tight bound controls which digits are valid. When tight, you can't exceed .
Once you place a smaller digit, tight becomes false forever. You have full freedom for remaining positions. This is the simplest digit DP. Next, we'll add more state to track used digits. Apply these patterns when you encounter similar problems.