✅ C++ || Prefix Sum
c++\nclass Solution {\npublic:\n    vector<int> getSumAbsoluteDifferences(vector<int>& nums) {\n        int n = nums.size();\n        vector<int> pre(n + 1, 0);
```c++\nclass Solution {\npublic:\n    vector<int> getSumAbsoluteDifferences(vector<int>& nums) {\n        int n = nums.size();\n        vector<int> pre(n + 1, 0);\n        for (int i = 1; i < pre.size(); i++) pre[i] = pre[i-1] + nums[i-1];\n        vector<int> res(n, 0);\n        for (int i = 0; i < n; i++) {\n            auto left = i * nums[i] - pre[i];\n            auto right = pre[n] - pre[i + 1] - (n - i - 1) * nums[i];\n            res[i] =  left + right;\n        }\n        return res;\n    }  \n};\n```\n\n**For more solutions, check out this \uD83C\uDFC6  [GITHUB REPOSITORY](https://github.com/MuhtasimTanmoy/playground) with over 1500+ solutions.**
[]