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.文章来源:https://www.toymoban.com/news/detail-827325.html
Algorithm
f(0) = 1
f(1) = 10
f(k) = 9 * 9 * 8 * … * (9 - k + 2)文章来源地址https://www.toymoban.com/news/detail-827325.html
Code
class Solution:
def countNumbersWithUniqueDigits(self, n: int) -> int:
ans = [1, 10, 91, 739, 5275, 32491, 168571, 712891, 2345851]
return ans[n]
到了这里,关于Leetcode 357. Count Numbers with Unique Digits的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!