Lower bound implementation
static int lowerBound ( List < int > array , int value ) { int low = 0 ; int high = array . Count ; while ( low < high ) { int mid = ( low + high ) / 2 ; if ( value <= array [ mid ] ) { high = mid ; } else { low = mid + 1 ; } } return low ; }