Return answer
return ans >= Integer . MAX_VALUE ? - 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 ( Vector < Integer > vec , int low , int high , int element ) { int [ ] array = new int [ vec . size ( ) ] ; int k = 0 ; for ( Integer val : vec ) { array [ k ] = val ; k ++ ; }