Dynamic Programming21 sections · 916 units
Open in Course

Lessons from Digit Set

summary

1.1. Shorter numbers need separate handling. Count them with simple math: digitsk|digits|^k for each length k<lenk < len.

2.2. Tight bound controls which digits are valid. When tight, you can't exceed n[pos]n[pos].

3.3. Once you place a smaller digit, tight becomes false forever. You have full freedom for remaining positions. This is the simplest digit DP. Next, you'll add more state to track used digits.