Find index of last occurrence of greatest element less than key in array * Returns : an index in range [ 0 , n - 1 ] if key is not the least element in array , - 1 if * key is the least element in array
static int greatestlesser ( int low , int high , int key ) { int ans = - 1 ; while ( low <= high ) { int mid = low + ( high - low + 1 ) / 2 ; int midVal = a [ mid ] ; if ( midVal < key ) {