Best C++ solution || Beginner-friendly explanation || Beats 100% in both !!
Approach\n Describe your approach to solving the problem. \nWe need to take advantage of the fact that array nums is sorted in ascending order. Which means all 
# Approach\n<!-- Describe your approach to solving the problem. -->\nWe need to take advantage of the fact that array nums is sorted in ascending order. Which means all elements before index i are smaller than nums[i] and all elements after i are greater than nums[i]. Dry run the code to understand the solution.\n\n# Code\n```\nclass Solution {\npublic:\n    vector<int> getSumAbsoluteDifferences(vector<int>& nums) {\n        int leftSum = 0, rightSum = 0, n=nums.size();\n        vector<int> ans(n,0);\n        for(int i=0; i<n; i++)\n            rightSum += nums[i];\n        for(int i=0; i<n; i++){\n            ans[i] = (rightSum - (nums[i]*(n-i))) + ((nums[i]*i) - leftSum);\n            rightSum -= nums[i];\n            leftSum += nums[i];\n        }\n        return ans;\n    }\n};\n```
['C++']