Dynamic Programming21 sections · 916 units
Open in Course

LeetCode 2376 Count Special Integers - Problem Statement

LeetCode 2376

Given a positive integer nn, return the number of positive integers in [1,n][1, n] that have all distinct digits. For n=20n = 20: integers 11-1010 are all special (single digit or "10"). Integers 1111-2020: only 1111 has repeated digits.

Answer: 1919. For n=135n = 135: you need to count all numbers up to 135135 where no digit repeats. This requires tracking which digits you've used. Before reading the solution, try to identify the base case and recursive relationship yourself.