91% :: Prefix Sum
Use prefix sums. This problem was easy, so I think the code is pretty self explanatory.\n\n\nclass Solution:\n    def getSumAbsoluteDifferences(self, nums: List
Use prefix sums. This problem was easy, so I think the code is pretty self explanatory.\n\n```\nclass Solution:\n    def getSumAbsoluteDifferences(self, nums: List[int]) -> List[int]:\n        cumulative_nums = [nums[0]]\n        for i in range(1, len(nums)):\n            cumulative_nums.append(nums[i] + cumulative_nums[-1])\n        \n        ans = [0] * len(nums)\n        for i in range(len(nums)):\n            if i < len(nums) - 1:\n                ans[i] = (cumulative_nums[-1] - cumulative_nums[i]) - nums[i] * (len(nums) - 1 - i)\n            if i > 0:\n                ans[i] += nums[i] * i - cumulative_nums[i - 1]\n        return ans\n```
[]