prefix sum java solution
class Solution {\n    public int[] getSumAbsoluteDifferences(int[] nums) {\n        int sum=0;\n        int prefix=0;\n        int res[]=new int[nums.length];\n
# class Solution {\n    public int[] getSumAbsoluteDifferences(int[] nums) {\n        int sum=0;\n        int prefix=0;\n        int res[]=new int[nums.length];\n        for(int a:nums)\n        {\n           sum+=a; \n        }\n        for(int i=0;i<nums.length;i++)\n        {\n            prefix+=nums[i];\n            res[i]=((i+1)*nums[i]-prefix)+((sum-prefix)-((nums.length-1-i)*nums[i]));\n        }\n        return res;\n    }\n}
['Prefix Sum', 'Java']