Java O(N) sliding window
\nclass Solution {\n    static final int MOD=1000000007;\n    public int waysToSplit(int[] nums) {\n        var len=nums.length;\n        for(int i=1;i<len;i++)
```\nclass Solution {\n    static final int MOD=1000000007;\n    public int waysToSplit(int[] nums) {\n        var len=nums.length;\n        for(int i=1;i<len;i++) {\n            nums[i]+=nums[i-1];\n        }\n        int l=0,r=0,cnt=0;\n        for(int i=0;i<len;i++) {\n            l=Math.max(i+1,l);\n            while(l<len&&nums[l]-nums[i]<nums[i]) l++;\n            r=Math.max(l,r);\n            while(r<len-1&&nums[len-1]-nums[r]>=nums[r]-nums[i]) r++;\n            cnt+=r-l;\n            cnt%=MOD;\n        }\n        return cnt;\n    }\n}\n```
[]