C++ || Easy to understand || No Extra Space
\nclass Solution {\npublic:\n    int minimumAverageDifference(vector<int>& nums) \n    {\n        int n = nums.size();\n        long long totalSum = 0;\n       
```\nclass Solution {\npublic:\n    int minimumAverageDifference(vector<int>& nums) \n    {\n        int n = nums.size();\n        long long totalSum = 0;\n        for (int num : nums) totalSum += num;\n        //=======================================================================\n        int mnAvgDiff = INT_MAX, mnAvgDiffIdx = -1;\n        long long preSum = 0;\n        for (int i = 0; i < n; i++)\n        {\n            preSum += nums[i];\n            long long postSum = totalSum - preSum;\n            //==================================================\n            int preCount = i + 1;\n            int postCount = n - preCount;\n            int preAvg = preSum / preCount;\n            int postAvg = (postCount == 0)? 0 : (postSum / postCount);\n            //====================================================\n            int avgDiff = abs(preAvg - postAvg);\n            if (avgDiff < mnAvgDiff)\n            {\n                mnAvgDiff = avgDiff;\n                mnAvgDiffIdx = i;\n            }\n        }\n        //=======================================================================\n        return mnAvgDiffIdx;\n    }\n};\n```
['C', 'C++']