AlgoScope

Digit DP

TechniqueexpertAdvanced Dynamic Programming

Count numbers in a range with a digit property by processing digits with a "tight" flag.

Decision · step 3 of 8Digit DP: Numbers up to 275 without a 7
pos 0pos 1pos 2endtightfree6191

Position 2, tight: 275 has the digit 5 here. A digit below 5 frees the rest: 5 allowed choices x 1 = 5. Choosing 5 itself keeps the number tight, adding the tight count of the next position, 1. Total 6.

Open in the player →or start at step 3

What you will see

Digit positions as columns; the tight flag splits each column in two.

How digit dp works →

Cost

BestO(digits * states)
AverageO(digits * states)
WorstO(digits * states)
SpaceO(digits * states)

How you work with it here

play it through, step one change at a time, scrub to any step, run it on your own input, predict what happens next.

Screen readers: Table cells announce their state and value; each step announces which cells were read and the value written.

Reduced motion: Dependency arrows appear statically and the cell value crossfades.

Before this