Problem Brief
Count Numbers with Unique Digits
OA
See Salesforce online assessment and hiring insights
Given a list of numbers, count the number of numbers in the range [l,r] such that the number does not contain duplicate digits.
1Example 1
Input
numbers = [1, 2, 11, 55, 989, 51, 60, 7007], l = 1, r = 5
Output
2
Explanation
In the given range [1,5], the numbers 1 and 2 do not contain any duplicate digits, so the answer is 2.
(Explanation may not be 100% correct. For reference only. If you find anything wrong, pls feel free to lmk! Many thanks in advance!)
2Example 2
Input
numbers = [1, 2, 11, 55, 989, 51, 60, 7007], l = 0, r = 7
Output
4
Explanation
In the given range [0,7], the numbers 1, 2, 5 (from 51), and 6 (from 60) do not contain any duplicate digits, so the answer is 4.
(Explanation may not be 100% correct. For reference only. If you find anything wrong, pls feel free to lmk! Many thanks in advance!)
3Example 3
Input
numbers = [1, 2, 11, 55, 989, 51, 60, 7007], l = 5, r = 7
Output
2
Explanation
In the given range [5,7], the numbers 5 (from 51) and 6 (from 60) do not contain any duplicate digits, so the answer is 2.
(Explanation may not be 100% correct. For reference only. If you find anything wrong, pls feel free to lmk! Many thanks in advance!)