Concise Prefix Sum | C++
\nclass Solution {\npublic:\n    vector<int> getSumAbsoluteDifferences(vector<int>& nums) {\n        int n = nums.size();\n        vector<int> ps = nums, ans(n)
```\nclass Solution {\npublic:\n    vector<int> getSumAbsoluteDifferences(vector<int>& nums) {\n        int n = nums.size();\n        vector<int> ps = nums, ans(n);\n        for(int i=1; i<n; i++) ps[i] += ps[i - 1];\n        \n        for(int i=0; i<n; i++) {\n            ans[i] = abs((ps[n - 1] - ps[i]) - (nums[i] * (n - i - 1)));\n            ans[i] += abs((ps[i] - nums[i]) - (nums[i] * i));\n        }\n        return ans;\n    }\n};\n```
['Suffix Array', 'C++']