Problem · Array
Count Numbers with Unique Digits
Learn this problemProblem statement
Given a list of numbers, count the number of numbers in the range [l,r] such that the number does not contain duplicate digits.
Function
countUniqueDigits(numbers: int[], l: int, r: int) → intExamples
Example 1
numbers = [1, 2, 11, 55, 989, 51, 60, 7007]l = 1r = 5return = 2In 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!)
Example 2
numbers = [1, 2, 11, 55, 989, 51, 60, 7007]l = 0r = 7return = 4In 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!)
Example 3
numbers = [1, 2, 11, 55, 989, 51, 60, 7007]l = 5r = 7return = 2In 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!)
More Salesforce problems
- Minimize Total Input Cost (for LTMS)Seen Jun 2026
- Count Prime StringsONSITE INTERVIEW · Seen Jun 2026
- Final Pod Counts After LogsOA · Seen May 2026
- ATM Queue Exit OrderPHONE SCREEN · Seen May 2026
- Good Ways to Split an ArrayPHONE SCREEN · Seen May 2026
- Generate Seen Binary StringsOA · Seen May 2026
- Update Pod Counts From LogsOA · Seen May 2026
- Minimum Removals to Balance ArrayOA · Seen May 2026