Hard

Quiz

#233 Number of Digit One

APPROACH

Given an integer n, compute and return the total count of the digit 1 appearing across all non-negative integers from 0 to n inclusive.

Example 1:

Input: n = 13
Output: 6

Example 2:

Input: n = 0
Output: 0
1 of 4
1:00

What is the optimal approach for this problem?