Easy C++
\n# Approach\nBy checking average upto index\n Describe your approach to solving the problem. \n\n# Complexity\n- Time complexity: O(n)\n Add your time complexi
\n# Approach\nBy checking average upto index\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity: $$O(n)$$\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: $$O(1)$$\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:\n    int minimumAverageDifference(vector<int>& nums) {\n        long long minAv = INT_MAX;\n        int idx = 0;\n        long long sSum = 0, eSum = accumulate(nums.begin(),nums.end(),(long long)0);\n        long long p=0,q=nums.size();\n        for(int i=0;i<nums.size();i++){\n            sSum += nums[i];\n            eSum -= nums[i];\n            p++, q--;\n            long long av1 = sSum / p;\n            long long av2;\n            if(q==0)\n                av2 = 0;\n            else\n                av2 = eSum / q;;\n            if(abs(av1-av2) < minAv){\n                minAv = abs(av1-av2);\n                idx = i;\n            }\n        }\n        return idx;\n    }\n};\n```
['C++']