Dynamic Programming21 sections · 916 units
Open in Course

Challenge: Digit Set Edge Cases

Handling tricky inputs

What if the digit set doesn't include 0? We can't form numbers like 101101. The DP handles this naturally by only trying available digits. What if N=0N = 0? The answer is 0 (or 1 if we count 0 as valid). Check your base case. What if the digit set is {0}\{0\}? Only 0 is valid.

But leading zeros mean we only count actual 0, not "00" or "000". What if N<N < smallest digit? Answer is 0. The DP will find no valid paths at the first position.