scala twoliner. sliding window, three pointers
```scala []\nobject Solution {\n  def maxFrequencyScore(nums: Array[Int], _k: Long): Int = {\n    val ns = (Vector(Long.MaxValue) ++ nums.iterator.map(_.toLong)).sorted\n    Iterator.unfold((0,0,0,0L,0L)){case x@(i,j,k,lsum ,rsum) =>\n      Option.when(k<ns.length-1){\n        if(j-i < k-j)\n          (x, (i,j+1,k,lsum+(j-i+1)*(ns(j+1)-ns(j)), rsum-(k-j)*(ns(j+1)-ns(j))))\n        else if(rsum+lsum <= _k)\n          (x, (i,j,k+1,lsum,rsum + ns(k+1) - ns(j)))\n        else\n          (x, (i+1,j,k,lsum - (ns(j) - ns(i)),rsum ))\n      }\n    }.collect{case (i,j,k,lsum ,rsum) if lsum+rsum <= _k => k-i+1}.max\n  }\n}\n```
['Sliding Window', 'Sorting', 'Scala']