Company: ibm_29sep
Difficulty: medium
Array Challenge Problem Description For each element in an array, implement a function that: Initializes a counter to 0 for each element. 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. Function Description Complete the function arrayChallenge in the editor with the following parameter(s): int arr[] : an array of integers Returns int[] : an array of integers calculated as described Examples Example 1: Input: n = 3, 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. Testing arr[2] = 3 , first against 4, counter = 0 - |3 - 4| = -1 , and then agains