A support system gives each ticket an ID from 1 upward. To make IDs easy to read aloud, a team wants to know how many IDs from 1 to n have no repeated digit (for example 1234 qualifies, 1213 does not).
Write countUniqueDigitIds(n) that returns how many integers from 1 to n (inclusive) have all different digits.
Input: n = 20 Output: 19
Every number from 1 to 20 except 11.
Input: n = 100 Output: 90
1 to 9 (9 numbers), plus the 81 two-digit numbers without a repeat. 100 repeats 0.
1 <= n <= 10^9Run tries your code on the examples. Submit runs every test, including hidden edge cases, and solves the problem when they all pass.
Ctrl + Enter runs, Ctrl + Shift + Enter submits (⌘ on a Mac).
I'm here to help with #562 Count IDs With Unique Digits. I give hints, never the solution, so you get to solve it yourself. Ask for a hint, select code to ask about it, or press Ask Tuto why on a failing test.
Your first 3 answers need no account. for free to keep asking.