Problem
Given an integer n, return the count of all numbers with unique digits, x, where 0 < = x < 1 0 n 0 <= x < 10^n 0<=x<10n.
Algorithm
f(0) = 1
f(1) = 10
f(k) = 9 * 9 * 8 * … * (9 - k + 2)
Code
class Solution:
def countNumbersWithUniqueDigits(self, n: int) -> int:
ans = [1, 10, 91, 739, 5275, 32491, 168571, 712891, 2345851]
return ans[n]