Skip to main content

Digit Constraints

Learn Digit Constraints (Dynamic Programming, Advanced DSA) with worked examples, diagrams and interview questions. Free on JavaSchoolLab.

Adding More Tracked Properties to Digit DP Beyond just "tight or free", Digit DP problems often need EXTRA state to track a running property - counting numbers with no two adjacent equal digits needs the PREVIOUS digit; counting numbers with digit sum divisible by k needs the running SUM MOD k. Each new constraint adds one more dimension to the memoization state.

More lessons in Dynamic Programming