Given an integer array nums of length n, return an integer array answer where answer[i] = |leftSum[i] - rightSum[i]|.
leftSum[i] = sum of all elements to the left of index i (or 0).rightSum[i] = sum of all elements to the right of index i (or 0).
Input: An integer array nums of length n.
Output: Integer array answer of length n.
Input: [10,4,8,3]
Output: [15,1,11,22]
Explanation: i=0: |0-(4+8+3)|=15. i=1: |10-(8+3)|=1. i=2: |(10+4)-3|=11. i=3: |(10+4+8)-0|=22.Input: [1]
Output: [0]
Explanation: Single element. leftSum=rightSum=0. |0-0|=0.Input: [1,2,3,4,5]
Output: [14,11,6,1,10]
Explanation: i=0:|0-14|=14. i=1:|1-12|=11. i=2:|3-9|=6. i=3:|6-5|=1. i=4:|10-0|=10.1<=nums.length<=10001<=nums[i]<=10^5