A printing service charges extra for page numbers where two neighboring digits are the same, like 112 or 3455, because the font kerning looks odd. A document uses page numbers from low to high.
Write countCleanPages(low, high) that returns how many integers from low to high (inclusive) have no two equal neighboring digits.
Input: low = 95, high = 112 Output: 13
There are 18 numbers, minus 99, 100, 110, 111, and 112.
Input: low = 5, high = 5 Output: 1
A single digit has no neighbors.
1 <= low <= high <= 10^15Run tries your code on the examples. Submit runs every test, including hidden edge cases, and solves the problem when they all pass.
Ctrl + Enter runs, Ctrl + Shift + Enter submits (⌘ on a Mac).
I'm here to help with #564 Page Numbers Without Repeated Neighbors. I give hints, never the solution, so you get to solve it yourself. Ask for a hint, select code to ask about it, or press Ask Tuto why on a failing test.
Your first 3 answers need no account. for free to keep asking.