How to solve LeetCode problem 357: Counting numbers with unique digits?
- 内容介绍
- 文章标签
- 相关推荐
本文共计419个文字,预计阅读时间需要2分钟。
描述:给定一个非负整数n,计算所有具有唯一数字的数x的个数,其中0 ≤ x ≤ 10^n。例如:输入:2 输出:91 解释:答案应为0到10^2(即100)范围内的总数,排除11、22、33、44、55、66等。
Description
Given a non-negative integer n, count all numbers with unique digits, x, where 0 ≤ x < 10n.
Example:
Input: 2Output: 91
Explanation: The answer should be the total numbers in the range of 0 ≤ x < 100,
excluding 11,22,33,44,55,66,77,88,99
分析
题目的意思是:找一个范围内的各位上不相同的数字,比如123就是各位不相同的数字,而11,121,222就不是这样的数字。
本文共计419个文字,预计阅读时间需要2分钟。
描述:给定一个非负整数n,计算所有具有唯一数字的数x的个数,其中0 ≤ x ≤ 10^n。例如:输入:2 输出:91 解释:答案应为0到10^2(即100)范围内的总数,排除11、22、33、44、55、66等。
Description
Given a non-negative integer n, count all numbers with unique digits, x, where 0 ≤ x < 10n.
Example:
Input: 2Output: 91
Explanation: The answer should be the total numbers in the range of 0 ≤ x < 100,
excluding 11,22,33,44,55,66,77,88,99
分析
题目的意思是:找一个范围内的各位上不相同的数字,比如123就是各位不相同的数字,而11,121,222就不是这样的数字。

