class BinarySearch {
    companion object {
        fun search(inpList: List<Int>, searchElement: Int): Int {
            require(inpList.sorted() == inpList)
            var leftBound = 0
            var rightBound = inpList.size - 1
            while (leftBound <= rightBound){
                val middle = Math.floor(((leftBound + rightBound)/2).toDouble()).toInt()
                if (inpList[middle] < searchElement){
                    leftBound = middle + 1
                }
                else if (inpList[middle] > searchElement){
                    rightBound = middle - 1
                }
                else return middle
            }
            return -1
        }
    }
}