SIMPLE SOLUTION || c++ || O(1) space
\nclass Solution {\npublic:\n    int minimumAverageDifference(vector<int>& nums) {\n        int ans=INT_MAX;\n        long long total=0;  \n        int n=nums.s
```\nclass Solution {\npublic:\n    int minimumAverageDifference(vector<int>& nums) {\n        int ans=INT_MAX;\n        long long total=0;  \n        int n=nums.size();  //size of vector\n        \n        for(int i=0;i<n;i++){\n            total+=nums[i];    //total sum of all elements\n        }\n        \n        long long curr=0;\n        int ind=-1;\n        for(int i=0;i<n-1;i++){\n            curr+=nums[i];     //sum of elements upto current index i\n            long long last=total-curr;      //sum of remaining elements\n            long long p=abs((curr/(i+1))-(last/(n-i-1)));        //average \n            if(p<ans){     // taking min average difference and updating index\n                ans=p;\n                ind=i;\n            }\n        }\n        long long p=(total/n);\n        if(p<ans){       // taking min average difference and updating index for last index (n-1)\n            ans=p;\n            ind=n-1;\n        }\n        \n        return ind;      //return index of min average difference\n    }\n};\n\n\n\n```
['Prefix Sum']