Problems > Adjacent Digits Differ by 2+ > Editorial

Adjacent Digits Differ by 2+ — Solution & Editorial

Back to the Problem

Digit DP with prefix difference and tight/leading flags.

Complexity: O(digits · states)