Use Prefix Sum  | CPP SOLUTION
\n  int minimumAverageDifference(vector<int>& nums)\n    {\n        long long int n=nums.size();\n        long long int pre[n];\n        pre[0]=nums[0];\n      
```\n  int minimumAverageDifference(vector<int>& nums)\n    {\n        long long int n=nums.size();\n        long long int pre[n];\n        pre[0]=nums[0];\n        for(int i=1;i<n;i++)\n        {\n            pre[i]=pre[i-1]+nums[i];  //Here we are making prefix sum array whic reduce the complexity of finding sum for each index ...\n        }\n        int average=INT32_MAX;  //for comparison\n       \n        int a,b,index;\n        for(int i=0;i<n;i++)\n        {\n             a=pre[i]/(i+1);\n            if(i!=(n-1))  //important condition because at every n-1 index our n-i-1 condition gives 0 value which will return runtime error exception . from explanation we are able to understood that at each n-1 index b==0\n               b=(pre[n-1]-pre[i])/(n-i-1);\n            else\n                b=0;\n            long long int maxi=abs(a-b);\n           \n            if(maxi<average)\n            {\n                if(maxi==0)\n                {\n                    return i;//this is lowest difference possible hence we are returning the index of that index\n                }\n                else\n                {\n                average=maxi;\n                index=i;\n                }\n                \n            }\n        }\n        return index;\n        \n    }``\n```
[]