I solved https://leetcode.com/problems/total-waviness-of-numbers-in-range-ii/ but I had to have claude walk me through all of it because I couldn't understand any of the blogposts online
digit DP is exactly what you expect, it's like backtracking in that it builds an "array" of the current digit prefix in memory and then based on the conditions applies the computed result to all subsequent numbers you can generate with that prefix.
so
[1,2,3,4] -> [1,2,3,4,1], [1,2,3,4,2], [1,2,3,4,3] ... etc
//if state is true at prefix [1,2,3,4], then it's true at every following number built off the prefix
let (nextState, numsMadeFromPrefix) = dp(idx + 1)
totalState += nextState + (isStateValidAtPrefix * numsMadeFromPrefix)
totalCount += numsMadeFromPrefix
maybe I should've gone into healthcare instead of computer science