Python O(n) Solution, Commented
\nclass Solution:\n    def waysToSplit(self, nums: List[int]) -> int:\n        #Initialise variables\n        # left and right are the minimum left and maximum 
```\nclass Solution:\n    def waysToSplit(self, nums: List[int]) -> int:\n        #Initialise variables\n        # left and right are the minimum left and maximum right ends of the middle subarray\n        MOD, sz, left, right = 1000000007, len(nums), 0, 0\n        # Create a prefix array so that we can get subarray sums in O(1)\n        prefix, res = list(accumulate(nums)), 0\n        for idx in range(sz - 2):\n            # creating a left wall for the particular idx where the sum of left subarray would be\n            # less than or equal to the middle subarray\n            while left <= idx or (left < sz - 1 and prefix[left] < prefix[idx] * 2):\n                left += 1\n            # creating a right wall for the particular idx where the sum of middle subarray would be\n            # less than or equal to the right subarray\n            while right < left or (right < sz - 1 and prefix[right] - prefix[idx] <= prefix[-1] - prefix[right]):\n                right += 1\n            # updating res\n            # the number of possible middle subarrays is (max right - min left) + 1\n            res = (res + right - left) % MOD\n        return res\n```
['Prefix Sum', 'Python']