Function to implement upper_bound ( )
function upperBound ( array , length , value ) { let low = 0 ; let high = length ; while ( low < high ) { let mid = Math . floor ( ( low + high ) / 2 ) ; if ( value >= array [ mid ] ) { low = mid + 1 ; } else { high = mid ; } } return low ; }