Prefix Sum simple c++ solution
//T.C -> O(n) as we have traversed through a single loop\n\t\t//S.C -> O(n) as we have usead extra space for prefixSum vector\n\t\t\n\t\t//Approach -> we will s
//T.C -> O(n) as we have traversed through a single loop\n\t\t//S.C -> O(n) as we have usead extra space for prefixSum vector\n\t\t\n\t\t//Approach -> we will store prefix sum for each index in a vector and after that for every index we will keep on subtracting prefixSum at that index from total Sum and keep taking diffrrence of their averages.     When this difference becomes less than minimum difference than we will update our index to that current index..\n\t\t\n\t\t\n\t\tif(nums.size()==1){\n            return 0;\n        }\n        \n        vector<long long int>prefixSum(nums.size());\n        prefixSum[0]=nums[0];\n        long long int total=nums[0];\n        \n        for(int i=1;i<nums.size();i++){\n            prefixSum[i]=nums[i]+prefixSum[i-1];\n            total+=nums[i];\n        }\n        \n        int min_diff=INT_MAX;\n        int index=0;\n        \n    \n        for(int i=0;i<nums.size()-1;i++){\n            int val1=prefixSum[i]/(i+1);\n            int val2=(total-prefixSum[i])/(nums.size()-i-1);\n            \n            if(abs(val1-val2)<min_diff){\n                min_diff=abs(val1-val2);\n                index=i;\n            }\n            \n        }\n        \n        int last=total/nums.size();\n        if(last<min_diff){\n            return nums.size()-1;\n        }\n        \n        return index;
['C', 'Prefix Sum']