Count Numbers with Unique Digits

Medium

Description

Given a non-negative integer n, return the count of all numbers x in the range 0 <= x < 10^n where x has all unique digits.

Examples

Input:n = 2
Output:91
Explanation:

[0,99] minus duplicates.

Input:n = 0
Output:1
Explanation:

Edge case with minimal input.

Input:n = 1
Output:10
Explanation:

Numbers in range [0, 10) are {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}. All single-digit numbers have unique digits by definition, so all 10 numbers are valid.

Constraints

  • 0 ≤ n ≤ 8

Ready to solve this problem?

Practice solo or challenge other developers in a real-time coding battle!