C++ || Two Solutions || Prefix Sum || Simple Easy Solution
class Solution {\npublic:\n//Time Complexicity: O(N)\n//Sapce Complexicity: O(N)\n\n\n\n    int minimumAverageDifference(vector& nums) {\n        int n=nums.siz
class Solution {\npublic:\n//Time Complexicity: O(N)\n//Sapce Complexicity: O(N)\n\n\n\n    int minimumAverageDifference(vector<int>& nums) {\n        int n=nums.size();\n        vector <long long int> v(n,0);\n        v[0]=nums[0];\n        for(int i=1; i<n; i++){\n            v[i]=v[i-1]+nums[i];\n        }\n        int ans=0;\n        int max=INT_MAX;\n        for(int i=0; i<n-1; i++){\n            long long int x=v[i]/(i+1);\n            long long int y=v[n-1]-v[i];\n            y=y/(n-i-1);\n            if(max>abs(y-x)){\n                ans=i;\n                max=abs(x-y);\n            }\n        }\n        if(max>v[n-1]/n){\n            ans=n-1;\n        }\n        return ans;\n    }\n};\n//Time Complexicity: O(N)\n//Space Complexicity: O(1)\n\nclass Solution {\npublic:\n    \n    int minimumAverageDifference(vector<int>& nums) {\n        int n=nums.size();\n        long long int right=accumulate(nums.begin(),nums.end(),0ll);\n        long long int left=0;\n        long long int ans=0;\n        long long int max=INT_MAX;\n        for(int i=0; i<n-1; i++){\n            left+=nums[i];\n            long long int x=left/(i+1);\n            long long int y=right-left;\n            y=y/(n-i-1);\n            long long int j=abs(x-y);\n            if(max>abs(y-x)){\n                 max=j;\n                ans=i;\n            }\n        }\n        if(max>(left+nums[n-1])/n){\n            ans=n-1;\n        }\n        return ans;\n    }\n};\n
['C', 'Prefix Sum']