Distinct Digit Numbers
Learn this problemProblem statement
Given a range of integers, determine how many numbers have no repeating digits.
For n = 80 and m = 120, the bounds are inclusive, so there are 120 - 79 = 41 values in the range. Of these, 27 have no repeated digits and 14 contain a repeated digit, so the answer is 27.
Function
countNumbers(arr: int[][]) → int[]Examples
Example 1
arr = [[1, 20], [9, 19]]return = [19, 10]Row 0 [1, 20] The set of qualifying numbers in the inclusive range between n[0] = 1 and m[0] = 20 is {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 13, 14, 15, 16, 17, 18, 19, 20}. This gives us c[0] = 19.
Row 1 [9, 19] The set of qualifying numbers in the inclusive range between n[1] = 9 and m[1] = 19 is {9, 10, 12, 13, 14, 15, 16, 17, 18, 19}. This gives us c[1] = 10.
Example 2
arr = [[7, 8], [52, 80], [34, 84], [57, 64], [74, 78]]return = [2, 26, 47, 8, 4]Row 0 [7, 8] The set of qualifying numbers in the inclusive range between n[0] = 7 and m[0] = 8 is {7, 8}. This gives us c[0] = 2.
Row 1 [52, 80] The set of qualifying numbers in the inclusive range between n[1] = 52 and m[1] = 80 is {52, 53, 54, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 78, 79, 80}. This gives us c[1] = 26.
Row 2 [34, 84] The set of qualifying numbers in the inclusive range between n[2] = 34 and m[2] = 84 is {34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 78, 79, 80, 81, 82, 83, 84}. This gives us c[2] = 47.
Row 3 [57, 64] The set of qualifying numbers in the inclusive range between n[3] = 57 and m[3] = 64 is {57, 58, 59, 60, 61, 62, 63, 64}. This gives us c[3] = 8.
Row 4 [74, 78] The set of qualifying numbers in the inclusive range between n[3] = 74 and m[3] = 78 is {74, 75, 76, 78}. This gives us c[4] = 4.
Constraints
More JPMorgan Chase problems
- Bitwise XOR SubsequencesOA · Seen Jul 2026
- Array ChallengeOA · Seen Jun 2026
- Minimum Cores to Handle ProcessesOA · Seen Jun 2026
- About ShippingOA · Seen Jun 2026
- Count Dropped RequestsOA · Seen Jan 2026
- Generate Table of ContentsOA · Seen Jan 2026
- Calculate Net ProfitSeen Jun 2025
- Find Total WeightSeen Jun 2025