Class Solution

java.lang.Object
g0201_0300.s0233_number_of_digit_one.Solution

public class Solution extends java.lang.Object
233 - Number of Digit One.

Hard

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 <= 109
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    int
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Solution

      public Solution()
  • Method Details

    • countDigitOne

      public int countDigitOne(int n)