Given an integer n, return the total number of times the digit 111 appears in all non negative integers less than or equal to n.
n
Constraints:
0≤0 \leq0≤ n ≤109\leq 10^9≤109
Now, let’s take a moment to make sure you’ve correctly understood the problem. The quiz below helps you check if you’re solving the correct problem:
Number of Digit One
Given n = 1, how many times does the digit (1) appear in all integers from (0) through n?
n = 1
(1)
(0)
(2)
(10)
We have a game for you to play. Rearrange the logical building blocks to develop a clearer understanding of how to solve this problem.
Implement your solution in the following coding playground.