Number of Digit One

Given an integer A,
find and return the total number of digit 1 appearing in all non-negative integers less than or equal to A.



Input Format

The only argument given is the integer A.

Output Format

Return the total number of digit 1 appearing in all non-negative integers less than or equal to A.

Constraints

0 <= A <= 10^9

For Example

Input 1:
    A = 10
Output 1:
    2

Input 2:
    A = 20
Output 2:
    12
NOTE: You only need to implement the given function. Do not read input, instead use the arguments to the function. Do not print the output, instead return values as specified. Still have a doubt? Checkout Sample Codes for more details.
Start solving Number of Digit One on Interview Code Editor
Sign Up
to access hints and editorial solutions for Number of Digit One

Discussion


Loading...
Click here to start solving coding interview questions