C++ | O(N log N) | Prefix Sums + Binary Search
\n\tint waysToSplit(vector<int>& nums) {\n        int n=nums.size();\n        int pref[n];\n        for(int i=0;i<n;i++){\n            if(i==0){\n              
```\n\tint waysToSplit(vector<int>& nums) {\n        int n=nums.size();\n        int pref[n];\n        for(int i=0;i<n;i++){\n            if(i==0){\n                pref[i]=nums[i];\n            }else{\n                pref[i]=nums[i]+pref[i-1];\n            }\n        }\n        int ans=0,i2=0,mod=1e9+7;\n        for(int j=1;j+1<n;j++){\n            while(i2+1<j && pref[i2+1]<=pref[j]-pref[i2+1]){\n                i2++;\n            }\n            if(pref[n-1]-pref[j]<pref[j]-pref[i2]){\n                continue;\n            }\n            if(pref[j]-pref[i2]<pref[i2]){\n                continue;\n            }\n            int lo=-1,hi=i2;\n            while(hi-lo>1){\n                int mid=(lo+hi)/2;\n                if(pref[j]-pref[mid]<=(pref[n-1]-pref[j])){\n                    hi=mid;\n                }else{\n                    lo=mid;\n                }\n            }\n            ans=(ans+i2-hi+1)%mod;\n        }\n        return ans;\n    }`\n```
[]