How will you efficiently count number of occurrences of 0's in the decimal representation of integers from 1 to N?
e.g. The number of 0's from 1 to 105 is 16. How?
10,20,30,40,50,60,70,80,90,100,101,102,103,104,105
Count the number of 0's & you will find it 16.
Obviously, a brute force approach won't be appreciated. You have to come up with an approach which doesn't depend on "How many numbers fall between 1 to N". Can we just do by seeing some kind of pattern?
Cannot we extend the logic compiled here to work for this problem?