Binary Search Solution | C++ | O(nlogn)
\nconst int MOD = (int)(1e9) + 7 ;\nclass Solution {\npublic:\n    vector<int> getPrefix(vector<int> &a, int &n){\n        vector<int> prefix(n, 0) ; prefix[0] 
```\nconst int MOD = (int)(1e9) + 7 ;\nclass Solution {\npublic:\n    vector<int> getPrefix(vector<int> &a, int &n){\n        vector<int> prefix(n, 0) ; prefix[0] = a[0] ;\n        for(int i = 1 ; i < n ; i++) prefix[i] = prefix[i-1] + a[i] ;\n        return prefix ;\n    }\n    int waysToSplit(vector<int>& nums) {\n        int len = nums.size(), res = 0 ;\n        vector<int> prefix = getPrefix(nums, len) ;\n        for(int i = 0 ; i <= len - 1 ; i++){\n            int cur = prefix[i] ;\n            int mnMid = cur ;\n            int mxMid = ( prefix[len-1] - cur ) / 2 ;\n            if( cur > mxMid ) break ;\n            int j = lower_bound(prefix.begin() + i + 1, prefix.end() - 1, cur + mnMid ) - prefix.begin() ;\n            int k = upper_bound(prefix.begin() + i + 1, prefix.end() - 1, cur + mxMid ) - prefix.begin() - 1 ;\n            res = ( res + k - j + 1 ) % MOD ;\n        }\n        return res ;\n    }\n};\n```
[]