✅C++ || ✅Prefix Sum || ✅Commented Solution || ✅Easy
\nclass Solution {\npublic:\n    int minimumAverageDifference(vector<int>& nums) \n    {\n        int n = nums.size();\n        long long total = 0;\n        lo
```\nclass Solution {\npublic:\n    int minimumAverageDifference(vector<int>& nums) \n    {\n        int n = nums.size();\n        long long total = 0;\n        long long curr = 0;\n        for(auto it : nums) total += it;\n        \n        long long res;\n        long long temp = INT_MAX;\n        \n        for(int i=0;i<n;i++)\n        {\n            curr += nums[i];                          // curr left sum\n            long long avg1 = curr/(i+1);                    // left part avg\n            \n            // if we are on last idx then just check for left part\n            if(i==n-1)\n            {\n                if(avg1 < temp) \n                    return n-1;\n                else \n                    break;\n            }\n            \n            long long avg2 = (total-curr)/(n-i-1);          // right part avg\n            \n            // if we got a new min val then update index\n            if(abs(avg1-avg2) < temp)\n            {\n                temp = abs(avg1-avg2);\n                res = i;\n            }\n        }\n        \n        return res;\n    }\n};\n```
['C', 'Prefix Sum']