Solution by Average Coder :) , If you are struggling, check it once
```\nTo all average coders out there like me,i know many are struggling to understand these long codes\nwell let me explain :)\n\nconsider --> (1,1,1) by this e
```\nTo all average coders out there like me,i know many are struggling to understand these long codes\nwell let me explain :)\n\nconsider --> (1,1,1) by this example we can understand we can divide it by (1),(1),(1)\nso basically to get sum of subarrays we will use prefix sum array right!, then \n\n1,to satisfy 2nd part greater than first part,its value must be min of first part ,so we choose the index of lower bound of left part sum L[i],\n2,ans same to third part 2nd part value should can have max of third part value,which is half of remaining sum ,as we already cutted l[i]\n\njust try to understand clearly by pen and paper using this example: (1,2,2,5,0)\nhere sum is 12\nprefix sum array is (1 3 5 10 10)\nso here\ncase one:left part: 1\nthen middle part prefix sum should have atleast 2*1=2;\nand max can go upto half of remaning sum,as rest half would be third part right?,are you getting it?\n\nclass Solution {\npublic:\n    int waysToSplit(vector<int>& nums) {\n        int sum=0;\n        int n=nums.size();\n        \n        vector<int>pre(n,0);\n        pre[0]=nums[0];\n        \n        for(int i=1;i<n;i++)\n            pre[i]=pre[i-1]+nums[i];\n        \n        long long int ans=0;\n        int l,r;\n        for(int i=0;i<nums.size();i++)\n        {\n          l=pre[i];\n          r=pre[nums.size()-1]-l;\n          int x=lower_bound(pre.begin()+i+1,pre.end(),2*l)-pre.begin();\n          int y=upper_bound(pre.begin()+i+1,pre.begin()+nums.size()-1,l+r/2)-pre.begin();\n            \n            if(y>x)\n                ans+=y-x;\n        }\n        return ans%1000000007;\n    }\n};\n
[]