C++  Easy math binary search
find the prefix sum of array\nlet pre be the prefix sum of nums;\n\nwe require 2 wall to be placed in array\n\nthe position of first wall is decided by i in loo
find the prefix sum of array\nlet pre be the prefix sum of nums;\n\nwe require 2 wall to be placed in array\n\nthe position of first wall is decided by i in loop\n\nlet j and k give us the max and min index of second wall in the solution\n\nmin index of second wall   and max index of second wall \n\nsum( 0 to i ) <=  sum( i+1   j )  &&   sum( i+1 k) <=sum (k+1 n-1)\n\npre[ j ] - pre[ i ]  >= pre[ i ]   &&  pre[ k ] - p [ i ] <= p[ n-1 ] - p[ k ];\n\npre[ j ]>=2 pre[ i ]  -> lower_bound  in ( i+1  to  n-2 , 2 pre[ i ] )  n-2 as this is second wall so atleast one element should be after second wall;\n\npre[ k ]<= ( p[ n-1 ] + p[ i ] )/2; -> upper_bound-1 in ( i+1  to n-2 ,  ( p[ n-1 ] + p[ i ] )/2 ) \n```\nclass Solution {\npublic:\n    int mod=1000000007;\n    int waysToSplit(vector<int>& nums) {\n        int n=nums.size();\n        for(int i=1;i<n;i++)\n            nums[i]+=nums[i-1];\n        long int ans=0;\n        for(int i=0;i<n-2;i++)\n        {   \n            int j=lower_bound(nums.begin()+i+1,nums.end()-1,2*nums[i])-nums.begin();\n           \n            int k=upper_bound(nums.begin()+i+1,nums.end()-1,(nums[i]+nums[n-1])/2)-nums.begin()-1;\n             \n            ans=(ans%mod+max(0,k-j+1))%mod;\n        }\n        \n        return ans%mod;\n    }\n};\n```
['C']