Class Solution

  • All Implemented Interfaces:

    
    public final class Solution
    
                        

    1012 - Numbers With Repeated Digits.

    Hard

    Given an integer n, return the number of positive integers in the range [1, n] that have at least one repeated digit.

    Example 1:

    Input: n = 20

    Output: 1

    Explanation: The only positive number (<= 20) with at least 1 repeated digit is 11.

    Example 2:

    Input: n = 100

    Output: 10

    Explanation: The positive numbers (<= 100) with atleast 1 repeated digit are 11, 22, 33, 44, 55, 66, 77, 88, 99, and 100.

    Example 3:

    Input: n = 1000

    Output: 262

    Constraints:

    • <code>1 <= 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 numDupDigitsAtMostN(Integer n)
      • Methods inherited from class java.lang.Object

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