Class Solution

java.lang.Object
g2301_2400.s2376_count_special_integers.Solution

public class Solution extends Object
2376 - Count Special Integers.<p>Hard</p> <p>We call a positive integer <strong>special</strong> if all of its digits are <strong>distinct</strong>.</p> <p>Given a <strong>positive</strong> integer <code>n</code>, return <em>the number of special integers that belong to the interval</em> <code>[1, n]</code>.</p> <p><strong>Example 1:</strong></p> <p><strong>Input:</strong> n = 20</p> <p><strong>Output:</strong> 19</p> <p><strong>Explanation:</strong> All the integers from 1 to 20, except 11, are special. Thus, there are 19 special integers.</p> <p><strong>Example 2:</strong></p> <p><strong>Input:</strong> n = 5</p> <p><strong>Output:</strong> 5</p> <p><strong>Explanation:</strong> All the integers from 1 to 5 are special.</p> <p><strong>Example 3:</strong></p> <p><strong>Input:</strong> n = 135</p> <p><strong>Output:</strong> 110</p> <p><strong>Explanation:</strong> There are 110 integers from 1 to 135 that are special.</p> <p>Some of the integers that are not special are: 22, 114, and 131.</p> <p><strong>Constraints:</strong></p> <ul> <li><code>1 <= n <= 2 * 10<sup>9</sup></code></li> </ul>
  • Constructor Details

    • Solution

      public Solution()
  • Method Details

    • countSpecialNumbers

      public int countSpecialNumbers(int n)