Adjacent Digits Differ by One — Solution & Editorial
Digit DP with prefix difference and tight/leading flags.
Complexity: O(digits · states)
Watch out: Leading zeros exempt; a single-digit number trivially satisfies the condition.
Digit DP with prefix difference and tight/leading flags.
Complexity: O(digits · states)
Watch out: Leading zeros exempt; a single-digit number trivially satisfies the condition.