Class Solution

  • All Implemented Interfaces:

    
    public final class Solution
    
                        

    2376 - Count Special Integers\.

    Hard

    We call a positive integer special if all of its digits are distinct.

    Given a positive integer n, return the number of special integers that belong to the interval [1, n].

    Example 1:

    Input: n = 20

    Output: 19

    Explanation: All the integers from 1 to 20, except 11, are special. Thus, there are 19 special integers.

    Example 2:

    Input: n = 5

    Output: 5

    Explanation: All the integers from 1 to 5 are special.

    Example 3:

    Input: n = 135

    Output: 110

    Explanation: There are 110 integers from 1 to 135 that are special.

    Some of the integers that are not special are: 22, 114, and 131.

    Constraints:

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

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