Number of Digit One

Asked at Amazon · Coding Questions · Difficulty: Medium

Given an integer `n`, count the total number of digit `1` appearing in all non-negative integers from `0` to `n` (equivalently `1..n`).

Loading the problem…