Company: IBM___.
Difficulty: medium
Array Challenge Problem Description For each element in an array, implement a function that: Initializes a counter to 0. Compares the element with each element to its left: If the left element is greater, subtract the absolute difference from the counter. If the left element is smaller, add the absolute difference to the counter. Returns a new array containing the final counter values for each element. Example Suppose arr = [2, 4, 3] . Output: [0, 2, 0] Explanation: For arr[0] = 2 , the counter starts at 0. There are no elements to the left, so the counter is 0. For arr[1] = 4 , the counter starts at 0 and then increases by |4 - 2| = 2 at the first and only comparison. The counter is 2. For arr[2] = 3 , first against 4, the counter becomes 0 - |3 - 4| = -1 . Then, against 2, the counter becomes -1 + |3 - 2| = 0 . Constraints 1 ≤ size of arr ≤ 10 5