Easy and simple explaination for daily challenge | Prefix and suffix | c++
\nclass Solution {\npublic:\n    vector<int> getSumAbsoluteDifferences(vector<int>& nums) {\n        \n        int n = nums.size();\n        \n        vector<in
```\nclass Solution {\npublic:\n    vector<int> getSumAbsoluteDifferences(vector<int>& nums) {\n        \n        int n = nums.size();\n        \n        vector<int> prefix(n,0);\n        \n        prefix[0] = nums[0];\n        \n        for(int i=1;i<n;i++){\n            prefix[i] = prefix[i-1] + nums[i];\n        }\n        \n        vector<int> suffix(n,0);\n        \n        suffix[n-1] = nums[n-1];\n        \n        for(int i=n-2;i>=0;i--){\n            suffix[i] = nums[i] + suffix[i+1];\n        }\n        \n        vector<int> ans(n,0);\n        \n        for(int i=1;i<n-1;i++){\n            int val = abs(i*nums[i]-prefix[i-1]) + abs((n-i-1)*nums[i] - suffix[i+1]);\n            ans[i] = val;\n        }\n        ans[0] = abs((n-1)*nums[0] - suffix[1]);\n        ans[n-1] = abs((n-1)*nums[n-1] - prefix[n-2]);\n        \n        return ans;\n    }\n};\n```
['C', 'Prefix Sum']