612. Digit Count in Range
Given a single-digit integer d and two integers low and high, return the number of times that d occurs as a digit in all integers in the inclusive range [low, high].
Example 1:
Input: d = 2, low = 2, high = 25
Output: 9
Explanation:
The digit d = 2 occurs 9 times in 2,20,12,21, 22, 23, 24,25.
Example 2:
Input: d = 3, low = 100, high = 250
Output: 35
Explanation:
The digit d = 3 occurs 35 times in 103,113,123,130,131,...,238,239,243.
Now Your Turn!
Pick the correct output for the given inputInput: d = 1, low = 1, high = 13
Still unsure what the problem is asking ?
Let’s go through a few more examples, step by step, to make it clearer.
Constraints:
- 0 <= d <= 9
- 1 <= low <= high <= 2 * 108