Leetcode 357 Solution
This article provides solution to leetcode question 357 (count-numbers-with-unique-digits)
Access this page by simply typing in "lcs 357" in your browser address bar if you have bunnylol configured.
Leetcode Question Link
https://leetcode.com/problems/count-numbers-with-unique-digits
Solution
class Solution {
public:
int countNumbersWithUniqueDigits(int n) {
int total = 1;
int curr = 1;
for (int i = 0; i < n; i++)
{
if (i == 0)
curr = 9;
else
curr *= 10 - i;
total += curr;
}
return total;
}
};