JavaScript & Go 3 Pointers Time: O(n) Space: O(1)
Simple solution to find the first index and last index of the middle section\njavascript\nvar waysToSplit = function(nums) {\n    const mod = 1000000007;\n    c
Simple solution to find the first index and last index of the middle section\n```javascript\nvar waysToSplit = function(nums) {\n    const mod = 1000000007;\n    const lastIndex = nums.length - 2;\n    const total = nums.reduce((sum, num) => sum + num)\n\n    let midLeftPtr = -1;\n    let midRightPtr = -1;\n    \n    let leftSum = 0;\n    let midLeftSum = 0;\n    let midRightSum = 0;\n    \n    let numWaysToSplit = 0;\n    \n    for (let leftPtr = 0; leftPtr < nums.length; leftPtr++) {\n        leftSum += nums[leftPtr];        \n        midLeftSum -= nums[leftPtr];\n        midRightSum -= nums[leftPtr];\n\n       // find the first index that satisfies the middle sum\n\t   // being greater than or equal to the left sum\n        while (midLeftPtr <= lastIndex && \n               (midLeftPtr <= leftPtr || midLeftSum < leftSum)) {\n            midLeftPtr++;\n            midLeftSum += nums[midLeftPtr]\n        }\n\n        // find the first index that makes the middle sum greater than the right sum\n        while (midRightPtr <= lastIndex && \n               (midLeftPtr > midRightPtr || midRightSum <= total - midRightSum - leftSum)) {\n            midRightPtr++\n            midRightSum += nums[midRightPtr]\n        }\n        numWaysToSplit = (numWaysToSplit + midRightPtr - midLeftPtr) % mod;\n    }\n    return numWaysToSplit\n};\n```\n```go\n/////////////////////////////////////////////////////////////////////////////////////////////////////\n/////////////////////////////////////////////////////////////////////////////////////////////////////\n/////////////////////////////////////////////////////////////////////////////////////////////////////\n\n\nfunc waysToSplit(nums []int) int {\n    mod := 1000000007\n    lastIdx := len(nums) - 2\n    \n    \n    total, leftSum, midLeftSum, midRightSum := 0, 0, 0, 0\n    for _, num := range nums {\n        total += num\n    }\n    \n    midLeftIdx, midRightIdx := -1, -1\n    \n    numWaysToSplit := 0\n    for leftIdx := 0; leftIdx < lastIdx; leftIdx++ {\n        leftSum += nums[leftIdx]\n        midLeftSum -= nums[leftIdx];\n        midRightSum -= nums[leftIdx];\n\n        // find the first index that the middle section is valid\n        for (midLeftIdx <= lastIdx && \n               (midLeftIdx <= leftIdx || midLeftSum < leftSum)) {\n            midLeftIdx++;\n            midLeftSum += nums[midLeftIdx]\n        }\n\n        // find the first index that makes the comparison between the\n        // middle and right index invalid\n        for (midRightIdx <= lastIdx && \n               (midLeftIdx > midRightIdx || midRightSum <= total - midRightSum - leftSum)) {\n            midRightIdx++\n            midRightSum += nums[midRightIdx]\n        }\n        numWaysToSplit = (numWaysToSplit + midRightIdx - midLeftIdx) % mod;\n    }\n    return numWaysToSplit\n}\n```
['Go', 'JavaScript']