C++ | Easy and Simple | 90% fast
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\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) {\n        if(nums.size() == 1) return 0;\n        long long int sum1 = 0, sum2 = 0;\n\n        for(int i=0; i<nums.size(); i++) sum2 += nums[i];\n\n        int ans = -1;\n        int cnt = INT_MAX;\n\n        int n = nums.size();\n        for(int i=0; i<n-1; i++){\n            sum1 += nums[i];\n            sum2 -= nums[i];\n\n            long long int a = sum1/(i+1);\n            long long int b = sum2/(n-i-1);\n\n            if(cnt > abs(a-b)){\n                cnt = abs(a-b);\n                ans = i;\n            }\n        }\n\n        sum1 += nums[n-1];\n        if(sum1/n < cnt){\n            ans = n-1;\n        }\n\n        return ans;\n    }\n};\n```
['C++']