Javascript O(n) - With Explanation
\n/*\nWe use here leftSum since the values on the left is smaller than the current value,\nand rightSum since the right values are bigger than the current value
```\n/*\nWe use here leftSum since the values on the left is smaller than the current value,\nand rightSum since the right values are bigger than the current value,\nalso we use the count of values on left and on the right.\nfor example for [1, 4, 6, 8, 10],\nif we want to get the result of 6 \n- Result of the left side = |6-4| + |6-1| => 12-5 = 7 \n   =  its (currentValue * numbers of element on the left side) - sum of element on the left side\n- Result of the left side = |10-6| + |8-6| => 18-6 = 6\n   =  its sum of element on the right side - (currentValue * numbers of element on the right side) \nSo for 6 it\'s 6 + 7 = 13\n*/\n```\n\n```\nvar getSumAbsoluteDifferences = function (nums) {\n  let totalSum = 0;\n  let result = [];\n  for (let i = 0; i < nums.length; i++) {\n    totalSum += Math.abs(nums[i]);\n  }\n  let currentLeftSum = 0;\n  let leftElementsCount = 0;\n  let rightElementsCount = nums.length - 1;\n  for (let i = 0; i < nums.length; i++) {\n    currentLeftSum += nums[i];\n    let leftSum = (leftElementsCount * nums[i]) - (currentLeftSum - nums[i]);\n    let rightSum = (totalSum - currentLeftSum) - (rightElementsCount * nums[i]);\n    leftElementsCount++;\n    rightElementsCount--;\n    result[i] = Math.abs(leftSum + rightSum);\n  }\n  return result;\n};\n```\n```\n// T.C. O(n)\n// S.C. O(n)\n```
['JavaScript']