very intuitive approach in C++ O(N).
\nclass Solution {\npublic:\n    vector<int> getSumAbsoluteDifferences(vector<int>& nums) {\n        \n        \n        int n = nums.size();\n        int sum  
```\nclass Solution {\npublic:\n    vector<int> getSumAbsoluteDifferences(vector<int>& nums) {\n        \n        \n        int n = nums.size();\n        int sum  = 0 ; // using it for suffix sum.\n        for ( int i = 0 ; i< n ; i++ ){\n            sum += nums[i];\n        }\n        \n        \n        int curr_sum = 0; //using it for prefix sum.\n        int ans = 0;\n        \n        vector<int> res; \n        \n        for (int i  =0 ;i< n ;i++){\n            ans = 0;\n            curr_sum += nums[i];\n            \n            ans += (  (sum - curr_sum) - ( nums[i] * (n - i - 1) )  );\n                    //sum of elements after i // subtractes // with nums[i] * number of elements left.\n                    // i.e. for example [1,4,6,8,10]  and i = 2\n                    //  (8 + 10)  -  (6 * 2) = 6\n            \n            ans += ( (nums[i] * i ) - (curr_sum - nums[i] )  );\n                    //nums[i] * number of elements used // subtractes // with sum of elements before i. \n                    // i.e. for example [1,4,6,8,10]  and i = 2\n                    //  (6 * 2 )  -  (1 + 4) = 7\n            \n            //ans = 7 + 6 = 13\n            \n            res.push_back(ans);\n            \n        }\n        \n        return res;\n    }\n    \n};\n```
[]