Company: Adobe_15Aug
Difficulty: medium
Maximum Gross Value Problem Description Given an array arr of n integers, for a triplet (i), (j), (k) (i Here sum(x, y) is the sum of all the elements in the subarray arr[x...y]. Note that sum(x, y) is 0 as arr[x...y] is an empty subarray. Find out the maximum possible gross value of any valid triplet. Example arr = [-5, 3, 9, 4] Some gross value calculations i, j, k Gross Value ------- ------------------- 2, 3, 4 (-5) - (3) + 9 - 4 = -3 1, 3, 4 0 - (-2) + 9 - 4 = 7 1, 2, 5 0 - (-5) + 16 - 0 = 21 For row 1, arr(1,2) - arr(2,3) + arr(3,4) - arr(4,5) is shown. The maximum possible gross value is 21 for indices 1, 2, and 5. Function Description Complete the function getMaximumGrossValue in the editor below. getMaximumGrossValue has the following parameter: int arr[n] : the array Returns long : the maximum possible gross value of any valid triplet Constraints 1 -10^9 Examples Example 1: Input: arr_size = 4 arr = [-1, 1, 2, -2] Output: 6 Explanation: It is optimal to select (i) = 1, (j) = 2