✅✅ C++ || Easy Solution ||
Step by Step Approach---\n1-Calculate prefix sum for every index and store it in array.\n2-for every index calculate average difference and store its minimum va
**Step by Step Approach---\n1-Calculate prefix sum for every index and store it in array.\n2-for every index calculate average difference and store its minimum value index.\n***\n**Code**\n\'\'\'\n\nclass Solution {\npublic:\n\n    int minimumAverageDifference(vector<int>& nums) {\n        int n=nums.size();\n        if(n==1)    return 0;\n        long long pre[n]; //to store prefix sum\n        pre[0]=nums[0];\n\t\t\n\t\t//calculating prefix sum\n        for(int i=1;i<n;i++)    pre[i]=pre[i-1]+nums[i];\n\t\t\n        long long res=INT_MAX;\n        int ind=0;\n\t\t\n\t\t// calculating minimum average for i=0 to i=n-2\n        for(int i=1;i<n;i++) {\n            int k=(abs(pre[i-1]/i-(pre[n-1]-pre[i-1])/(n-i)));\n            if(res>k){\n                res=k;\n                ind=i-1;\n            }\n        }\n\t\t\n\t\t//special case for i=n-1\n        if(res>abs(pre[n-1]/n)){\n            res=abs(pre[n-1]/n);\n            ind=n-1;\n        }\n        return ind;\n    }\n};\n\'\'\'
['Math', 'C', 'Prefix Sum']