Skip to content

Practice Count Special Integers

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Hard#2376
LeetCode Problem

Count Special Integers

Problem Statement

We call a positive integer special if all of its digits are distinct. Given a positive integer n, return the number of special integers that belong to the interval [1, n].

Source: Count Special Integers on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
n = 20
Output
19

# Example 2

Input
n = 5
Output
5

# Example 3

Input
n = 135
Output
110

Constraints

1 <= n <= 2 * 10^9

Related LeetCode Problems

Practice more problems similar to Count Special Integers.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.