How to solve LeetCode problem 357: Counting numbers with unique digits?

2026-06-10 03:570阅读0评论SEO问题
  • 内容介绍
  • 文章标签
  • 相关推荐

本文共计419个文字,预计阅读时间需要2分钟。

How to solve LeetCode problem 357: Counting numbers with unique digits?

描述:给定一个非负整数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.

How to solve LeetCode problem 357: Counting numbers with unique digits?

Example:

Input: 2
Output: 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分钟。

How to solve LeetCode problem 357: Counting numbers with unique digits?

描述:给定一个非负整数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.

How to solve LeetCode problem 357: Counting numbers with unique digits?

Example:

Input: 2
Output: 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就不是这样的数字。

阅读全文