<p>Given an integer <code>n</code>, return the count of all numbers with unique digits, <code>x</code>, where <code>0 &lt;= x &lt; 10<sup>n</sup></code>.</p>

<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>

<pre>
<strong>Input:</strong> n = 2
<strong>Output:</strong> 91
<strong>Explanation:</strong> The answer should be the total numbers in the range of 0 &le; x &lt; 100, excluding 11,22,33,44,55,66,77,88,99
</pre>

<p><strong class="example">Example 2:</strong></p>

<pre>
<strong>Input:</strong> n = 0
<strong>Output:</strong> 1
</pre>

<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>

<ul>
	<li><code>0 &lt;= n &lt;= 8</code></li>
</ul>

class Solution {
public:
    int countNumbersWithUniqueDigits(int n) {
        if (n == 0) return 1;  // Only 0 is the valid number for n = 0
        
        int count = 10;  // Start with single-digit numbers (0 to 9)
        int unique_digits = 9;  // Number of unique digits for the next place
        int available_digits = 9;  // Number of remaining digits available to fill

        for (int i = 2; i <= n; i++) {
            unique_digits *= available_digits;  // Multiply by remaining available digits
            count += unique_digits;  // Add the number of unique digit numbers of length i
            available_digits--;  // Decrease available digits for the next place
        }
        
        return count;
    }
};

7300