No adjacent equal digits

Write codeHard35 min

Your task

Count integers x in [1, N] (decimal, no leading zeros) such that no two ADJACENT digits of x are equal. Return the count. Constraints: 1 <= N <= 10**18. A direct loop is infeasible; use digit DP tracking the previous digit, a tight flag, and a started flag (to handle leading zeros / the length).

Examples

count_no_adjacent_equal(N: int) -> int
Example 1
Inputcount_no_adjacent_equal(12)
Output11