help for 84/87
stuck at 84/87 where\nOutput:\n999949971\nExpected:\n999849973\n\nit is the case with many 0s\nnot sure are there any logic error with my code ?\n\nclass Soluti
stuck at 84/87 where\nOutput:\n999949971\nExpected:\n999849973\n\nit is the case with many 0s\nnot sure are there any logic error with my code ?\n\n```class Solution {\npublic:\n    int waysToSplit(vector<int>& nums) {\n        long long mod = 1e9 + 7;\n        int len = nums.size();\n        vector<long long> presum(len, 0);\n        presum[0] = nums[0];\n        long long sum = nums[0];\n        for(int idx = 1; idx < len; idx++) {\n            presum[idx] = nums[idx] + presum[idx-1];\n            sum += nums[idx];\n            \n        }\n        long long ans = 0;\n        for(int endIdx = 0; endIdx < len-2; endIdx++) {\n            int leftPart = presum[endIdx];\n            \n            //find the first left where middle larger than left\n            int left = endIdx + 1;\n            int right = len - 1;\n            while(left + 1 < right) {\n                int mid = left + (right - left) / 2;\n                int midSum = presum[mid] - leftPart;\n                if(midSum < leftPart) {\n                    left = mid;\n                }\n                else {\n                    right = mid;\n                }\n            }\n            int midPoint = -1;\n            if(presum[left] - leftPart >= leftPart) {\n                midPoint = left;\n            } \n            else if(presum[right] - leftPart >= leftPart) {\n                midPoint = right;\n            }\n            \n            if(midPoint == -1) {\n                break;\n            }\n            \n            left = midPoint;\n            right = len - 1;\n            while(left + 1 < right) {\n                \n                int mid = left + (right - left) / 2;\n                int midSum = presum[mid] - leftPart;\n                int rightSum = sum - presum[mid];\n                if(midSum > rightSum) {\n                    right = mid;\n                }\n                else {\n                    left = mid;\n                }\n            }\n            \n            int rightPoint = -1;\n            if(sum - presum[right] >= presum[right] - leftPart) {\n                rightPoint = right;\n            }\n            else if(sum - presum[left] >= presum[left] - leftPart) {\n                rightPoint = left;\n            }\n            \n            if(rightPoint != -1) {\n                ans = ans + rightPoint - midPoint + 1;\n                \n            }\n            \n        }\n        return int(ans % mod);\n        \n    }\n};\n\n```
['Binary Tree']