Numbers With Repeated Digits

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

Example 1
Inputn = 20
Output1
The only positive number less than or equal to 20 with at least one repeated digit is 11.
Example 2
Inputn = 100
Output10
The positive numbers less than or equal to 100 with at least one repeated digit are 11, 22, 33, 44, 55, 66, 77, 88, 99, and 100.

Constraints

  • 1 <= n <= 10^9

Asked at 2 companies

</>

Your Solution

(Ctrl/Cmd + Enter)

Switching Language

Loading template...

Loading...

Sign in to save your progress

AI code evaluation

Get a correctness verdict, missed edge cases, and complexity analysis of your solution.

Sign in to evaluate