scala sliding window
```scala []
object Solution {
  def numMovesStonesII(stones: Array[Int]): Array[Int] = {
    lazy val sorted = stones.sorted
    lazy val delta = (stones.length - List(0,1).map{i => sorted(sorted.length-2+i)-sorted(i)-1}
      .min - 2) max 0
    lazy val mn = sorted.indices.foldLeft(0){case (lo,hi) =>
      if(sorted(hi)-sorted(lo) > stones.length) lo+1 else lo
    } + delta
    lazy val mx = sorted.last-sorted.head+1-sorted.length-
      List(1,sorted.length-1).map{i =>sorted(i)-sorted(i-1)-1}.min
    if(sorted.last-sorted.head+1==sorted.length) Array(0,0) else Array(mn,mx)
  }
}
```
['Two Pointers', 'Sliding Window', 'Scala']