Simple and Easy C++ code | Beat 100%
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:\n    vector<int> getSumAbsoluteDifferences(vector<int>& nums) {\n        ios_base::sync_with_stdio(false);\n        cin.tie(NULL);\n        cout.tie(NULL);\n\n        int n = nums.size();\n        vector<int> preSum(n, 0);\n\n        preSum[0] = nums[0];\n        for (int i = 1; i < n; i++)\n            preSum[i] = preSum[i - 1] + nums[i];\n\n        for (int i = 0; i < n; i++) {\n            int leftSum = i * nums[i] - (i > 0 ? preSum[i - 1] : 0);\n            int rightSum = (preSum[n - 1] - preSum[i]) - (n - 1 - i) * nums[i];\n\n            nums[i] = leftSum + rightSum;\n        }\n\n        return nums;\n    }\n};\n```
['C++']