[Python] Binary Search O(n logn)
Binary Search Solution:\nFirst we need to build a prefix array which represent the prefix_sum of each index.\n\nThen we needs to cut the array into 3 pieces and
**Binary Search Solution:**\nFirst we need to build a prefix array which represent the prefix_sum of each index.\n\nThen we needs to cut the array into 3 pieces and each piece len > 0,\nSo we have two cut index\n\nUse the second cut index and make it as `j`,  for each j we need to find the range of the first cut index, which in my code represented as `lo and hi`, the way to find `lo and hi` is by using binary search.\n\nTime Complexity O(n logn)\nSpace Complexity O(n)\n\nIf you like my post, please upvote it :)\n\n```\nclass Solution:\n    def waysToSplit(self, nums: List[int]) -> int:\n        ans, mod = 0, 10**9+7\n        prefix, prefixs = 0,  [0]*len(nums)\n        for i in range(len(nums)):\n            prefix += nums[i]\n            prefixs[i] = prefix\n    \n        j = len(nums)-2\n    \n        while j >= 2 and prefixs[len(nums)-1] - prefixs[j] < prefix//3:\n            j -= 1\n        while j >= 1:\n            last = prefixs[len(nums)-1]-prefixs[j]\n            rem = prefixs[j]\n            hi = bisect.bisect_right(prefixs, rem//2, 0, j-1)\n            if prefixs[hi] > rem//2: hi -= 1\n            lo = bisect.bisect_left(prefixs, rem-last, 0, hi)\n            if prefixs[lo] < rem-last: lo += 1\n            if j >= hi >= lo >= 0 and last >= prefixs[len(nums)-1]-last-prefixs[lo]:\n                ans += hi-lo+1\n                ans %= mod\n            j -= 1\n    \n        return ans\n```
[]