Trains the technique from
LeetCode 357Count Numbers with Unique DigitsThis is an original problem, written from a brief that listed the technique, the difficulty, the topics, the function shape and the input bounds — none of that problem's wording, examples, hints or editorials. The link is there so you can map your practice onto the standard set.
Same function shape, different story and different numbers.
A depot stamps its crates with the whole numbers from 0 up to but not including 10^n. A stamp is clean when no digit occurs twice in it, written the ordinary way with no leading zeros: 9, 40 and 907 are clean, while 11, 121 and 900 are not.
Return how many stamps in that range are clean. When n is 0 the range holds the single number 0.
Example 1
The stamps run from 0 through 9. Each is a single digit, so none of them repeats a digit and all ten are clean.
Example 2
The stamps run from 0 through 999, and 739 of them use no digit twice. For instance 5, 40 and 907 count, while 11, 121 and 900 do not.
Example 3
The stamps run from 0 through 99999, and 32491 of them use no digit twice. For instance 13579 counts, while 13577 does not.
The editor is preloaded with this. It matches the parent problem's shape, so a solution that works here transfers to a judge unchanged.
def count_clean_stamps(n: int) -> int:public int countCleanStamps(int n)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.