hardDynamic ProgrammingMathRecursion 0 views

Number of Digit One

Given an integer n, count the total number of digit 1 appearing in all non-negative integers less than or equal to n.

Given an integer n, count the total number of digit 1 appearing in all non-negative integers less than or equal to n.

Example 1

Input: n = 13

Output: 6

Example 2

Input: n = 0

Output: 0

Constraints

  • 0 <= n <= 10^9

Hints

Companies

No companies reported yet.

Discussion

Sign in to join the discussion.

Loading discussion...

Test results

No test cases yet.