Count Numbers with Unique Digits

Given an integer n, return how many numbers x with 0 <= x < 10^n have no repeated digit.

30:00

Count Numbers with Unique Digits
medium
Free written solution
Topics
Companies

Given an integer n, return how many numbers x with 0 <= x < 10^n have no repeated digit.

Example 1:
Input: {"n":2}
Output: 91
Constraints:
  • 0≤n≤80 \leq n \leq 8

Test Cases
Input (Stdin)
Expected Output (Stdout)
Execution Result

Run code to see results.

Input
arr ={"n":2}

Count the numbers below 10^2 = 100 whose digits are all different. Group them by how many digits they have.

n = 2

no slots yet

unique numbers by digit count

nothing counted yet

choices = 0

total = 0

Variables
VariableValue
n2
DepthFunction Call
Stack empty
0/6