Count Numbers with Unique Digits LeetCode solution in Python

1
class Solution:
2
def countNumbersWithUniqueDigits(self, n: int) -> int:
3

4
if n == 0:
5
return 1
6

7
table = [0] * (n + 1)
8

9
table[0] = 1
10
table[1] = 9
11

12
for i in range(2, n + 1):
13
table[i] = table[i - 1] * (11 - i)
14

15
return sum(table)

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0