Skip to main content
LeetCode 357, Medium. Topics: Math, Dynamic Programming, Backtracking. View on LeetCode. Generate this problem as a practice environment: tested reference solution, 12 parametrized pytest cases, and a playground notebook:

Problem

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

Examples

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.

Constraints

  • 0 <= n <= 8

Solution

Reference implementation from solution.py on GitHub, full suite in test_solution.py:

Complexity

Tags

Last modified on September 7, 2026