scala O(n) prefix sum, sliding window, three pointers
all zeros is a special case here, does not fit into the model, but can be calculated w/o second pass
```
nums: 1 2 2 2  5  0
pfxs: 1 3 5 7 12 12
ptrs: i j . k
```
all zeros is a special case here, does not fit into the model, but can be calculated w/o second pass
```scala []
object Solution {
  def waysToSplit(nums: Array[Int]): Int = {
    lazy val pfx = nums.scanLeft(0){case (b,a) => b+a}.drop(1)
    lazy val x3 = pfx.indices.iterator
      .scanLeft((0L,0,0)){case((acc,j,k),i) =>
        lazy val j2 = LazyList.range((i+1) max j,pfx.length)
          .dropWhile(j1 => pfx(j1)-pfx(i)<pfx(i)).headOption.getOrElse(pfx.length)
        lazy val k2 = LazyList.range(j2 max k,pfx.length)
          .dropWhile(k1 => pfx.last-pfx(k1) >= pfx(k1)-pfx(i)).headOption.getOrElse(pfx.length)
        ((k2-j2), j2, k2)
      }.map(_._1).sum
    ((if(pfx.last == 0) (nums.length-2L)*(nums.length-1L)/2L else x3) % 1_000_000_007).toInt
  }
}
```
['Scala']