Ctrl K

Numbers with No Repeated Digit

Easy
You are given two integers low and high. A number qualifies when no digit appears twice in its decimal form: 507 qualifies, 377 does not. Return how many qualifying numbers lie between low and high inclusive.
Example 1
low=95, high=105 → 8

99, 100 and 101 repeat a digit; the other 8 numbers qualify.

Example 2
low=1, high=9 → 9

A one-digit number cannot repeat a digit, so all 9 qualify.

Example 3
low=330, high=334 → 0

Every number from 330 to 334 has two 3s, so the answer is 0.

Constraints
  • 1 ≤ low ≤ high ≤ 10⁹
Have you seen this problem in a real interview?
Solved by0
Tried by0
Submissions0
Acceptance—
Topics
Similar problemsNumbers Made of Twos, Threes and Fives MediumSquare-Sum Chains HardFewest Lines Through the Dots MediumMessages Behind Key Presses MediumPicks Without a Fixed Gap Medium
loading Python…
Input
low=95, high=105
Expected
8

Run checks the first 3 tests in your browser. Submit checks all 81 tests on the server, hidden ones included.