Given an input array of integers nums, find an integer array, let's call it differenceArray, of the same length as an input integer array.
Each element of differenceArray, i.e., differenceArray[i], should be calculated as follows: take the sum of all elements to the left of index i in array nums (let's call it leftSumi), and subtract it from the sum of all elements to the right of index i in array nums (let's call it rightSumi), taking the absolute value of the result:
differenceArray[i] = | leftSumi - rightSumi |
If there are no elements to the left or right of i, the corresponding sum should be taken as 0.
Example 1:
[2, 5, 1, 6, 1]
[13, 6, 0, 7, 14]
Example 2:
[3, 3, 3]
[6, 0, 6]
Example 3:
[1, 2, 3, 4, 5]
[14, 11, 6, 1, 10]
Constraints:
1 <= nums.length <= 1000