Using Prefix,Suffix Sum
\n\n\nclass Solution {\npublic:\n    int minimumAverageDifference(vector<int>& nums) {\n        vector<long long> left(nums.size());\n        vector<long long> 
\n\n```\nclass Solution {\npublic:\n    int minimumAverageDifference(vector<int>& nums) {\n        vector<long long> left(nums.size());\n        vector<long long> right(nums.size());\n        right[nums.size()-1]=0;\n        left[0]=nums[0];\n        for(int i=1;i<nums.size();i++)\n        {\n            left[i]=left[i-1]+nums[i];\n         \n        }\n         for(int i=nums.size()-2;i>=0;i--)\n        {\n           right[i]=right[i+1]+nums[i+1];\n         \n        }\n      \n       int  d=1e7;\n        int ans;\n        int n=nums.size()-1;\n        for(int i=0;i<nums.size();i++)\n        {\n            //cout<<n-i;\n            if(i==nums.size()-1)\n            {\n             if(left[i]/(i+1)<d)\n             {\n                ans=i;\n             }\n            }\n            else{\n            int a=abs(left[i]/(i+1)-right[i]/(n-i));\n            if(a<d)\n            {\n               \n                d=a;\n                ans=i;\n            }\n            }\n        }\n        return ans;\n    }\n};\n```\n\n\n\n\n     \n
['C', 'Prefix Sum', 'C++']