Numbers With Repeated Digits

Hard

Topics
MathDynamic Programming

Given an integer n, return the count of positive integers in the range [1, n] that have at least one repeated digit.

Example 1

Input:  n = 20
Output: 1
Explanation: Only 11 has a repeated digit.

Example 2

Input:  n = 100
Output: 10

Example 3

Input:  n = 1000
Output: 262

Constraints

  • 1 <= n <= 10^9
Run ⌘' · Submit ⌘⏎