Easy  Optimized and Understandable Solution[Prefix Sum] || TC - O(n)
Complexity\n- Time complexity:\nO(n)\n\n- Space complexity:\nO(1)\n\n# Code\n\nclass Solution {\npublic:\n    int minimumAverageDifference(vector<int>& nums) {\
# Complexity\n- Time complexity:\nO(n)\n\n- Space complexity:\nO(1)\n\n# Code\n```\nclass Solution {\npublic:\n    int minimumAverageDifference(vector<int>& nums) {\n\n        int maxi=INT_MAX ,res=0,n=nums.size();\n\n        long total=0,sum=0;\n\n        for(auto x : nums){\n\n            total+=x;\n        }\n        for(int i = 0;i<n-1;i++){\n\n\t\t\tsum+=nums[i];\n\n\t\t\tlong curr = abs(sum/(i+1) - (total-sum)/(n-i-1));\n\n\t\t\tif(curr<maxi) {\n                maxi = curr;\n                res = i;\n            }\n\t\t}\n\n\t\treturn maxi>total/n ? n-1:res;\n        \n    }\n//Please Upvote :)\n};\n```
['C++']