Answered step by step
Verified Expert Solution
Question
1 Approved Answer
n=4arr1=[2,1,3,4]arr2=[2,3,2,3] Some of the possible rearrangements are shown below. The maximum sum possible is 7 , and 7 modulo (109+7)=7. Function Description Complete the function
n=4arr1=[2,1,3,4]arr2=[2,3,2,3] Some of the possible rearrangements are shown below. The maximum sum possible is 7 , and 7 modulo (109+7)=7. Function Description Complete the function getMaxSumOfArray in the editor below. getMaxSumOfArray has the following parameter(s): arr1[n]: an array of integers arr2[n]: an array of integers Return int: the maximum possible sum, modulo (109+7). Constraints Constraints 1n1051arr1[i]1091arr2[i]109 Sample Input For Custom Testing STDIN3123310FUNCTIONarr1[]sizen=3arr1=[1,2,3]arr2[]sizen=3arr2=[10,10,10] Sample Output 50 Explanation Given n=3,arr1=[1,2,3] and arr2=[10,10,10]. Calculating arr3 using i * (arr2[i]arr1[i]),arr3=[9,16,21] and its sum will be 47. If arr1 is changed to [3,2,1] and arr2 remains unchanged i.e.[10,10,10]. Now the value of i * (arr2[i]arr1[i])=[7,16,27], and its sum is 50. In this case, 50 is the maximum sum
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started