Company: Amex SDE IIT Roorkee
Difficulty: medium
Count Digit One Problem Description Write a function: int solution(int N); that, given an integer N, returns the number of times the digit 1 occurs in decimal representations of all positive integers not exceeding N. Examples Example 1: Input: N = 13 Output: 6 Explanation: All the positive integers that do not exceed 13 are 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 and 13. The digit 1 occurs six times altogether: once in number 1, once in number 10, twice in number 11, once in number 12 and once in number 13. Constraints N is an integer within the range [0..100,000,000].