c++ binary search
\nclass Solution {\npublic:\n    int waysToSplit(vector<int>& nums) {\n        int n = nums.size(), mod = 1e9 + 7;\n        vector<int> prefix(n, 0);\n        l
```\nclass Solution {\npublic:\n    int waysToSplit(vector<int>& nums) {\n        int n = nums.size(), mod = 1e9 + 7;\n        vector<int> prefix(n, 0);\n        long count = 0;\n        prefix[0] = nums[0];\n        for (int i = 1; i < n; i++) {\n            prefix[i] = nums[i] + prefix[i - 1];\n        }\n     \n        for (int i = 0; i < n - 2; i++) {\n            int left = prefix[i];\n            int remain = prefix[n - 1] - left;\n            if (remain < left * 2) break;\n            int leftPtr = lower_bound(prefix.begin() + i + 1, prefix.end() - 1, left * 2) - prefix.begin();\n            int rightPtr = upper_bound(prefix.begin() + i + 1, prefix.end() - 1, left + remain / 2) - prefix.begin() - 1;\n            if (rightPtr - leftPtr + 1 > 0) count += rightPtr - leftPtr + 1;\n        }\n        \n        return count % mod;\n        \n    }\n};\n```
['C', 'Binary Tree']