✅ C++ || EASY || DETAILED EXPLAINATION || O(N) O(1)
\nclass Solution {\npublic:\n    int minimumAverageDifference(vector<int>& nums) {\n        long sum = 0,csum = 0;\n        int  n = nums.size();\n        \n   
```\nclass Solution {\npublic:\n    int minimumAverageDifference(vector<int>& nums) {\n        long sum = 0,csum = 0;\n        int  n = nums.size();\n        \n        for(auto x : nums) sum = sum + x;\n        \n        int min = INT_MAX, ans = 0;\n        \n        for(int i = 0; i<n; i++){\n            csum = csum + nums[i];\n            \n            int avg1 = csum/(i+1);\n            \n            if(i == n-1){\n                if(avg1<min){\n                    return n-1;\n                }\n                else\n                    break;\n            }\n            int avg2 = (sum - csum)/(n-i-1);\n            if(abs(avg1 - avg2)<min){\n                min = abs(avg1-avg2);\n                ans = i;\n            }\n            \n        }\n        return ans;\n    }\n};\n```
['Array', 'C', 'C++']