Simple prefix sum || C++
\nclass Solution {\npublic:\n    int minimumAverageDifference(vector<int>& nums) {\n        int n = nums.size();\n        vector<long long> pref(n+1,0);\n      
```\nclass Solution {\npublic:\n    int minimumAverageDifference(vector<int>& nums) {\n        int n = nums.size();\n        vector<long long> pref(n+1,0);\n        for(int i=1;i<=n;i++){\n            pref[i] = pref[i-1] + nums[i-1];\n        }\n        int ans = INT_MAX;\n        int index = 0;\n        for(int i = 1;i<=n;i++){\n            long long temp =(long long) abs(((pref[i]-pref[0])/(i)) - ((pref[n]-pref[i])/(n-i==0?1:n-i)));\n            cout<<temp<<endl;\n            if(temp<ans){\n                ans = temp;\n                index=i-1;\n            }\n        }\n        return index;\n    }\n};\n```
[]