C++ Solution using Binary Search and Prefix sum
\n# Code\n\nclass Solution {\npublic:\n    int waysToSplit(vector<int>& nums) {\n         int p1 = 0;\n         int p2 = 0;\n         int n = nums.size();\n    
\n# Code\n```\nclass Solution {\npublic:\n    int waysToSplit(vector<int>& nums) {\n         int p1 = 0;\n         int p2 = 0;\n         int n = nums.size();\n         for(int i = 1 ; i < n ; i++){\n            nums[i] += nums[i-1];\n         }\n         int mod = 1e9+7;\n         int ans = 0;\n         long long int finalans =0;\n         while(p1<n-2){\n            int l =  nums[p1];\n            int m = nums[p2] - l;\n            bool fl = 0;\n            while(p2<=p1 || (p2<n-1 && m<l )){\n                p2++;\n                m = nums[p2] - l;\n            }\n            if(p2 == n-1) break;\n            \n               int lo = p2;\n               int hi = n-2;\n               while(hi>=lo){\n                int mid = (lo+hi)>>1;\n                  m = nums[mid] - l;\n                  int r = nums[n-1]-nums[mid];\n                if(r>=m){\n                    lo = mid+1;\n                }\n                if(r<m){\n                     hi = mid-1;\n                }\n               }  \n               //cout<<p2<<"--"<<ans2<<endl;\n               finalans += (hi-p2+1);\n               finalans%=mod;\n           p1++;\n         }\n         return finalans;\n    }\n};\n```
['C++']