Company: JPMC Fte_30march
Difficulty: medium
You are given an integer array arr . For each element in the array, compute a value using the following process: Initialize a counter to 0 Compare the current element arr[i] with each element to its left ( arr[0] to arr[i-1] ) If a left element is greater than arr[i] , subtract the absolute difference from counter If a left element is smaller than arr[i] , add the absolute difference to counter Store the final value of counter for index i Return a new array containing the computed counter values for all elements in arr . Example Suppose arr = [2, 4, 3]. Output: [0, 2, 0] Explanation: For arr[0] = 2, counter starts at 0, and there are no elements to the left, so counter = 0. For arr[1] = 4, counter starts at 0 and then increases by | 4 - 2 | = 2 at the first and only comparison: counter = 2. Testing arr[2] = 3, first against 4, counter = 0 - | 3 - 4 | = -1, and then against 2, counter = -1 + | 3 - 2 | = 0. Constraints 1 ≤ size of arr[] ≤ 10 5 1 ≤ arr[i] ≤ 10 9 Test Case Inpu