Return answer
return ans >= int . MaxValue ? - 1 : ans ; } static int upper_bound ( int [ ] a , int low , int high , int element ) { while ( low < high ) { int middle = low + ( high - low ) / 2 ; if ( a [ middle ] > element ) high = middle ; else low = middle + 1 ; } return low ; } static int lowerBound ( List < int > vec , int low , int high , int element ) { int [ ] array = new int [ vec . Count ] ; int k = 0 ; foreach ( int val in vec ) { array [ k ] = val ; k ++ ; }