JAVA 3 pointer O(n)
\nclass Solution {\n    int MOD = 1_000_000_007;\n     public int waysToSplit(int[] nums) {\n        final int N = nums.length;\n        int[] prefix = new int[
```\nclass Solution {\n    int MOD = 1_000_000_007;\n     public int waysToSplit(int[] nums) {\n        final int N = nums.length;\n        int[] prefix = new int[N];\n         prefix[0]=nums[0];\n        for (int i = 1; i < N; i++) {\n          prefix[i] = prefix[i-1] + nums[i];\n        }\n        long res = 0;\n        int i1 = 1;\n        int i2 = 1;\n        for(int i=0;i<N-2;i++){\n            int left = prefix[i];\n            i1 = Math.max(i1,i+1);\n            while(i1<N-1&&prefix[i1]-left<left){\n                i1++;\n            }\n            \n            while(i2<N-1&&prefix[N-1]-prefix[i2]>=prefix[i2]-left){\n                i2++;\n            }\n            if(i2>i1&&i1<N-1){\n                res += (long) (i2 - i1);\n            }\n            \n        } \n        return (int) (res % MOD);\n  }\n}\n```
[]