Company: Msci_30july
Difficulty: medium
Maximize Array Correlation Problem Description For two arrays a and b of equal length, the array correlation is defined as the sum of all values b[i] where b[i] is greater than a[i] . Given two integer arrays a and b of the same length, rearrange the elements of array b to maximize the array correlation. Return the maximum possible array correlation value. Note: You are not allowed to rearrange the elements of the array a . Example Illustration: If n = 5, a = [1, 2, 3, 4, 5], b = [3, 5, 4, 6, 2] . One possible rearrangement of b is [2, 3, 4, 5, 6] . In this specific rearrangement, for each index, the integers in b are greater than those in a . The array correlation would then be 2 + 3 + 4 + 5 + 6 = 20. Function Description Complete the function getMaxArrayCorrelation in the editor with the following parameter(s): a[n] : the fixed order array b[n] : the array to reorder Returns: long int : the maximum possible array correlation Examples Example 1: Input: n = 5 a = [1, 4, 2, 1, 3] b = [2