c++ easy solution (o(n))
\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>& nu
\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        int ans;\n        int c_min = INT_MAX;\n        long long int avg = 0;\n        if(nums.size() == 1) return 0;\n        long long int total = 0;\n        for(int i = 0; i<nums.size(); i++){\n            total += nums[i];\n        }\n        for(int i = 0; i<nums.size(); i++){\n            avg += nums[i];\n           long long int c_avg = 0;\n            c_avg = total - avg;\n            if(nums.size()-1-i != 0)\n            c_avg = c_avg/(nums.size()-1-i);\n            else c_avg = 0;\n            int aavg = avg/(i+1);\n            if(abs(c_avg - aavg) < c_min){\n                c_min = abs(c_avg-aavg);\n                ans = i;\n            }\n        }\n        return ans;\n    }\n};\n```
['C++']