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. Examples Example 1 Input: 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 the 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. For arr[2] = 3 , first against 4, counter = 0 - |3 - 4| = -1, and then against 2, counter = -1 + |3 - 2| = 0. Example 2 Input: 3 2 1 3 Output: 0 -1 3 Note: The input format in the second image shows individual lines for array size and elements, resulting in arr = [2, 1, 3] . The output is printed on separ