Dynamic Programming21 sections · 916 units
Open in Course

Lessons from Special Integers

summary

1.1. Use bitmask to track used elements. Ten digits fit in a 10-bit integer.

2.2. Leading zeros need special handling. Don't mark 00 as used until you've started.

3.3. The base case checks "started." An empty number (all leading zeros) doesn't count. This pattern (digit DP + bitmask) appears whenever you need to track which digits or elements you've used. Apply these patterns when you encounter similar problems.