scala random pick
```scala []
class MajorityChecker(_arr: Array[Int]) {
  import scala.util.chaining._
  val aMap = _arr.toVector.zipWithIndex.groupMap(_._1)(_._2)
  def query(left: Int, right: Int, threshold: Int): Int = Iterator.range(0,21).flatMap{ _ =>
      lazy val num = _arr(util.Random.between(left,right+1))
      lazy val List(lip,rip) = List(left,right+1).map(aMap(num).search(_).insertionPoint)
      Option.when(rip-lip >= threshold)(num)
    }.take(1).toList.headOption.getOrElse(-1)
}

/**
 * Your MajorityChecker object will be instantiated and called as such:
 * val obj = new MajorityChecker(arr)
 * val param_1 = obj.query(left,right,threshold)
 */
```
['Scala']