Round 1
Questions:
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 between low[i] and high[i].
- low[i] <= high[i] for all possible i (1 <= i <= N).
Constraints:
- 1 <= N <= 10^5
- 1 <= low, high <= 10^6
Sample Input 1:
3 1 3 3 5
Sample Output 1:
40
Explanation: We 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.
Sample Input 2:
3 1 1 2 2
Sample Output 2:
8
Explanation: There is only a single way to choose 'brr' as [2,2,2] hence the answer will be 8.
Sample Input 3:
3 1 4 2 5
Sample Output 3:
30
Explanation: There is only a single way to choose 'brr' as [2,3,5] hence the answer will be 30.
Candidate's Approach
No approach provided.
Interviewer's Feedback
No feedback provided.