Prefix Sums + Binary Search | C++
\nclass Solution {\npublic:\n    int waysToSplit(vector<int>& arr) {\n        int mod =1e9+7;\n        int a=arr.size();\n        int pre[a];\n\tfor (int i = 0;
```\nclass Solution {\npublic:\n    int waysToSplit(vector<int>& arr) {\n        int mod =1e9+7;\n        int a=arr.size();\n        int pre[a];\n\tfor (int i = 0; i < a; i++) {\n\t\tif (i == 0) {\n\t\t\tpre[i] = arr[i];\n\t\t}\n\t\telse\n\t\t{\n\t\t\tpre[i] = pre[i - 1] + arr[i];\n\t\t}\n\t}\n\tlong long ans = 0;\n\tfor (int x = 0; x < a; x++) {\n\t\tint i = lower_bound(pre+x+1, pre + a, 2 * pre[x]) - pre;\n\t\tint j = upper_bound(pre, pre + a-1, (pre[a - 1] + pre[x]) / 2) - pre;\n\t\tif (j > i && j < a && i < a) {\n\t\t\tans += (j - i);\n\t\t}\n\t}\n\treturn ans%mod;\n    }\n};\n```
[]