C++ easy to understand Solution Beats 100%
Intuition\nDo the sum of all elements and observe.\n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time complexity:\nO(n)\n\n
# Intuition\nDo the sum of all elements and observe.\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        long sum=0,s=0;\n         for(int j=0;j<nums.size();j++)\n          {\n              s+=nums[j];\n          }\n          long min=INT_MAX;\n          int index=-1;\n        for(int i=0;i<nums.size();i++)\n        {\n            long avg=0;\n             sum+=nums[i];\n             s-=nums[i];\n            if(nums.size()-i-1>0)\n            {\n             avg=sum/(i+1)-s/(nums.size()-i-1);\n             avg=abs(avg);\n            }\n            else{\n                avg=abs(sum/(i+1));\n            }\n             if(avg<min)\n             {\n                 min=avg;\n                 index=i;\n             }\n        }\n        return index;\n    }\n};\n```
['C++']