Adjacent Digits
Given two integers a and b. The task is to count how many integers in the range [a, b] have no two adjacent digits equal.
Example:
112 → invalid (1 and 1 adjacent) 123 → valid 100 → invalid (0 and 0 adjacent)
Example 1:
Input: a = 123, b = 321
Output: 171
Explanation: We count all numbers between 123 and 321 where adjacent digits differ.
Example 2:
Input: a = 10, b = 15
Output: 5
Explanation : Valid numbers :10,12,13,14,15
Invalid: 11
Now Your Turn!
Pick the correct output for the given inputInput: a = 98 , b = 102
Still unsure what the problem is asking ?
Let’s go through a few more examples, step by step, to make it clearer.
Constraints:
- 0 ≤ a ≤ b ≤ 1018