Sum of Scores of Built Arrays
Learn this problemProblem statement
You have N ranges where the i-th range is from low[i] to high[i].
You need to create an array brr of length N. However, brr[i] can only be any prime number such that low[i] <= brr[i] <= high[i] for all possible i.
As we know there can be multiple ways to create brr. It is given that the score of an array is the multiplication of all values in it.
Your task is to find the sum of the score of all possible unique permutations of brr. Since the answer can be very large, return the answer modulo 10^9+7.
Note:
- It is guaranteed that there will be at least one element in
brr[i], which means there will always be a prime number betweenlow[i]andhigh[i]. low[i] <= high[i]for all possiblei(1 <=i<=N).
Function
sumOfScoresOfBuiltArrays(low: int[], high: int[]) → intExamples
Example 1
low = [1, 3]high = [3, 5]return = 40We have 2 ranges, [1,3] and [3,5], there can be 4 ways of choosing 'brr', [(2,3),(3,5), (2,5),(3,3)] and scores of these will be [6,15,10,9], so sum of scores will be 40.
Example 2
low = [1, 2, 2]high = [1, 2, 2]return = 8There is only a single way to choose 'brr' as [2,2,2] hence the answer will be 8.
Example 3
low = [1, 2, 3]high = [4, 5, 30]return = 30There is only a single way to choose 'brr' as [2,3,5] hence the answer will be 30.
Constraints
1 <= N <= 10^51 <= low[i], high[i] <= 10^6
More Uber problems
- Minimum Refueling StopsONSITE INTERVIEW · Seen Jul 2026
- Last Truck to Leave the LaneOA · Seen Jul 2026
- Chain of CommandOA · Seen Jul 2026
- Jump Game with Prime-3 StepsOA · Seen Jun 2026
- Total Palindrome Substring CostOA · Seen Jun 2026
- Earliest Time All Users Are ConnectedPHONE SCREEN · Seen May 2026
- Tournament Rounds by RankPHONE SCREEN · Seen May 2026
- Farthest Seat AssignmentONSITE INTERVIEW · Seen May 2026