```
public int countNumbersWithUniqueDigits(int n) {
int ret = 1, levelCnt = 9;
// n = Math.min(n, 10); // Removed since the input n is always <= 10
for (int k = 1; k <= n; k++) {
ret += levelCnt;
levelCnt *= (10-k);
}
return ret;
}
```