Count Numbers with Unique Digits

Given an integer n, return the count of all numbers with unique digits, x, where 0 <= x < 10^n.

Example 1
Inputn = 2
Output91
The total numbers in the range 0 <= x < 100 excluding repeated-digit numbers like 11, 22, 33, 44, 55, 66, 77, 88, and 99 is 91.
Example 2
Inputn = 0
Output1
When n = 0, the range is 0 <= x < 1, so only 0 is counted.

Constraints

  • 0 <= n <= 8

Asked at 3 companies

</>

Your Solution

(Ctrl/Cmd + Enter)

Switching Language

Loading template...

Loading...

Sign in to save your progress

AI code evaluation

Get a correctness verdict, missed edge cases, and complexity analysis of your solution.

Sign in to evaluate