587. Count Numbers with Unique Digits II

Given two positive integers a and b, return the count of numbers having unique digits in the range [a, b] (inclusive).

Example 1:

Input: a = 1, b = 20

Output: 19

Explanation: All the numbers in the range [1, 20] have unique digits except 11. Hence, the answer is 19.

Example 2:

Input: a = 9, b = 19

Output: 10

Explanation: All the numbers in the range [9, 19] have unique digits except 11. Hence, the answer is 10. 

Now Your Turn!

Pick the correct output for the given input

Input: a = 80, b = 120

Still unsure what the problem is asking ?

Let’s go through a few more examples, step by step, to make it clearer.

Constraints:

1 <= a <= b <= 1000

Hints

Frequently Occurring Doubts

Interview Follow-up Questions

0
class Solution {
public:
int numberCount(int a, int b) {
// User code goes here
}
};
Test Case

Input:

A
B