Back to the Problem
Digit DP with prefix difference; carry tight and leading-zero flags.
Complexity: O(digits · states)