lowerbound function
function lowerBound ( vec , low , high , element ) { let array = [ ... vec ] ; while ( low < high ) { let middle = Math . floor ( low + ( high - low ) / 2 ) ; if ( element > array [ middle ] ) { low = middle + 1 ; } else { high = middle ; } } return low + 1 ; }