Prefixsum|| VERY EASY || O(N)
\n class Solution {\n public: \n    \n\tvector getSumAbsoluteDifferences(vector& num) {     \n\t\tint n = num.size();\n        int sum=0;\n        for(int i=0;i
\n class Solution {\n public: \n    \n\tvector<int> getSumAbsoluteDifferences(vector<int>& num) {     \n\t\tint n = num.size();\n        int sum=0;\n        for(int i=0;i<n;i++){\n            sum += num[i];\n        }\n        int prev_sum=0;\n        int nxt_sum = sum;\n        int ans=0;\n        vector<int> v(n,0);\n        for(int i=0;i<n;i++){\n            v[i] = (n-i)*num[i]-nxt_sum;\n            v[i] = v[i] - (i)*num[i] + prev_sum;\n            prev_sum +=num[i];\n            nxt_sum = nxt_sum-num[i];\n        }\n        for(int i=0;i<n;i++){\n            v[i] = abs(v[i]);\n        }\n        return v;\n    }\n};
[]