Class Solution
java.lang.Object
g0201_0300.s0233_number_of_digit_one.Solution
233 - Number of Digit One.<p>Hard</p>
<p>Given an integer <code>n</code>, count <em>the total number of digit</em> <code>1</code> <em>appearing in all non-negative integers less than or equal to</em> <code>n</code>.</p>
<p><strong>Example 1:</strong></p>
<p><strong>Input:</strong> n = 13</p>
<p><strong>Output:</strong> 6</p>
<p><strong>Example 2:</strong></p>
<p><strong>Input:</strong> n = 0</p>
<p><strong>Output:</strong> 0</p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>0 <= n <= 10<sup>9</sup></code></li>
</ul>
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
Solution
public Solution()
-
-
Method Details
-
countDigitOne
public int countDigitOne(int n)
-