Class Solution

  • All Implemented Interfaces:

    
    public final class Solution
    
                        

    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:

    • <code>0 <= n <= 10<sup>9</sup></code>

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Field Summary

      Fields 
      Modifier and Type Field Description
    • Constructor Summary

      Constructors 
      Constructor Description
      Solution()
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      final Integer countDigitOne(Integer n)
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait