Concise Prefix Sum | C++
\nclass Solution {\npublic:\n    int minimumAverageDifference(vector<int>& nums) {\n        long long mn = INT_MAX, ans = 0, ls = 0, rs = 0, n = nums.size();\n 
```\nclass Solution {\npublic:\n    int minimumAverageDifference(vector<int>& nums) {\n        long long mn = INT_MAX, ans = 0, ls = 0, rs = 0, n = nums.size();\n        for(int i : nums) rs += i;\n\n        for(int i=0; i<n-1; i++) {\n            ls += nums[i];\n            rs -= nums[i];\n            int a = ls / (i + 1);\n            int b = rs / (n - i - 1);\n\n            if(abs(a - b) < mn) mn = abs(a - b), ans = i;\n        }\n        return (ls + nums.back()) / n < mn ? n - 1 : ans;\n    }\n};\n```
['Prefix Sum', 'C++']