What if n >= 10? I think we should consider this kind of input to make our code more robust.

```
class Solution {
public:
int countNumbersWithUniqueDigits(int n) {
int res[11];
res[0] = 1;
res[1] = 10;
for(int i = 2; i <= n && i <= 10; ++i) {
int base = 9, temp = 9;
while(temp >= 11 - i)
base *= temp--;
res[i] = res[i - 1] + base;
}
return n <= 10 ? res[n] : res[10];
}
};
```