Easy Java Solution...
Intuition\n Describe your first thoughts on how to solve this problem. \nIf we try out all possible solutions it would take O(n*n) at worst case scenario so i d
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nIf we try out all possible solutions it would take O(n*n) at worst case scenario so i did think of a prefix sum approach for handling sums efficiently and optimally.\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\nWe should have both prefix sum and post sum for a particular index to find a value in the resultant array \n-> pref should be decraased by nums[i] times of prefix length\n-> post should be decreased by nums[i] times of post length\nresultant would be pref + post apperently\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\nO(N)\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\nO(N)\n\n# Code\n```java []\nclass Solution {\n    public int[] getSumAbsoluteDifferences(int[] nums) {\n        int n=nums.length;\n        int pref[]=new int[n];\n        pref[0]=nums[0];\n        for(int i=1;i<n;i++)\n        {\n            pref[i]=pref[i-1]+nums[i];\n        }\n        int arr[]=new int[n];\n        for(int i=0;i<n;i++)\n        {\n            int pre=Math.abs(pref[i]-(i+1)*nums[i]);\n            int post=pref[n-1]-pref[i];\n            post-=(n-1-i)*nums[i];\n            arr[i]=pre+post;\n        }\n        return arr;\n    }\n}\n```
['Hash Table', 'Suffix Array', 'Prefix Sum', 'Java']