Explanation in code: Lower and Upper bounds
IntuitionApproachComplexity
Time complexity:

Space complexity:
Code
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->

# Approach
<!-- Describe your approach to solving the problem. -->

# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->

- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->

# Code
```cpp []
#define ll long long

class Solution {
public:
    int mod = 1e9+7;

    int waysToSplit(vector<int>& nums) {
        int n = nums.size();
        vector<int> pref(n+2, 0);
        pref[0] = nums[0];
        for(int i=1;i<n;i++){
            pref[i] += pref[i-1] + nums[i];
        }
        int cnt = 0;

        // left => 0 to i, mid = i+1 to j, right = j+1 to n-1

        // iterate through i
        for(int i=0;i<=n-3;i++){
            ll left = pref[i];
            ll rest = pref[n-1] - pref[i];

            /* to find mid sum
            sum(left) <= sum(mid)
            pref[i] <= pref[j] - pref[i]
            pref[j] >= pref[i] * 2
            means lower bound of 2*pref[i]
            */
            auto lb = lower_bound(pref.begin()+i+1, pref.begin()+n-1, 2 * left);
            /* sum(mid) <= sum(right)
            pref[j] - pref[i] <= pref[n-1] - pref[j]
            pref[j] <= (pref[i] + pref[n-1])/2
            pref[j] <= (pref[n-1]-pref[i])/2 + pref[i];
            pref[j] <= rest/2 + prf[i]
            pref[j] - pref[i] <= rest/2
            pref[j] <= rest/2 + pref[i]
            */
            auto ub = upper_bound(pref.begin()+i+1, pref.begin()+n-1, rest/2+left);
            if(ub - lb >= 0){
                cnt += ub-lb;
                cnt = cnt % mod;
            }
        }
        return cnt;



    }
};
```
['C++']