Company: Adobe_15Aug
Difficulty: medium
Maximum Gross Value Problem Description You are given an integer array arr of length n , indexed from 1 . Choose a triplet of indices i1 , i2 and i3 with 1 <= i1 <= i2 <= i3 <= n + 1 (inferred -- the visible source does not show this condition; it is the reading under which every allowed input, including n = 1 , has a valid triplet, and all source examples agree with it.) The three indices cut the array into four consecutive ranges. The gross value of the triplet is grossValue(i1, i2, i3) = sum[1, i1) - sum[i1, i2) + sum[i2, i3) - sum[i3, n + 1) where sum[l, r) is the sum of arr[l], arr[l + 1], ..., arr[r - 1] . The range includes index l and excludes index r . When l = r the range is empty and sum[l, r) = 0 . Find the maximum possible gross value over all valid triplets. Function Description Complete the function getMaximumGrossValue . getMaximumGrossValue has the following parameter: int arr[n] : the array It returns a long : the maximum possible gross value of any valid