Interview question of the issue #259 of rendezvous with cassidoo.
Given an integer n
, count the total number of 1
digits appearing in all non-negative integers less than or equal to n
.
Example:
> numberOfOnes(14)
> 7 // 1, 10, 11, 12, 13, 14
Just pnpm i
to install all dependencies and then pnpm t
to run the tests!