Return answer
return ans >= Number . MAX_VALUE ? - 1 : ans ; } function upper_bound ( a , low , high , element ) { while ( low < high ) { let middle = low + Math . floor ( ( high - low ) / 2 ) ; if ( a [ middle ] > element ) high = middle ; else low = middle + 1 ; } return low ; } function lowerBound ( vec , low , high , element ) { let array = new Array ( vec . length ) ; let k = 0 ; for ( let val = 0 ; val < vec . length ; val ++ ) { array [ k ] = vec [ val ] ; k ++ ; }