Class Solution
java.lang.Object
g1001_1100.s1012_numbers_with_repeated_digits.Solution
1012 - Numbers With Repeated Digits.<p>Hard</p>
<p>Given an integer <code>n</code>, return <em>the number of positive integers in the range</em> <code>[1, n]</code> <em>that have <strong>at least one</strong> repeated digit</em>.</p>
<p><strong>Example 1:</strong></p>
<p><strong>Input:</strong> n = 20</p>
<p><strong>Output:</strong> 1</p>
<p><strong>Explanation:</strong> The only positive number (<= 20) with at least 1 repeated digit is 11.</p>
<p><strong>Example 2:</strong></p>
<p><strong>Input:</strong> n = 100</p>
<p><strong>Output:</strong> 10</p>
<p><strong>Explanation:</strong> The positive numbers (<= 100) with atleast 1 repeated digit are 11, 22, 33, 44, 55, 66, 77, 88, 99, and 100.</p>
<p><strong>Example 3:</strong></p>
<p><strong>Input:</strong> n = 1000</p>
<p><strong>Output:</strong> 262</p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>1 <= n <= 10<sup>9</sup></code></li>
</ul>
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
Solution
public Solution()
-
-
Method Details
-
numDupDigitsAtMostN
public int numDupDigitsAtMostN(int n)
-