Returns - 1 if number x is greater than the largest element of arr
if n % 2 == 1 and arr [ r ] [ r ] < x : NEW_LINE INDENT return - 1 NEW_LINE DEDENT if n % 2 == 0 and arr [ r + 1 ] [ r ] < x : NEW_LINE INDENT return - 1 NEW_LINE DEDENT while l < r : NEW_LINE INDENT mid = ( l + r ) // 2 NEW_LINE if arr [ mid ] [ mid ] <= x : NEW_LINE INDENT if ( mid == ( n + 1 ) // 2 - 1 or arr [ mid + 1 ] [ mid + 1 ] > x ) : NEW_LINE INDENT return mid NEW_LINE DEDENT else : NEW_LINE INDENT l = mid + 1 NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT r = mid - 1 NEW_LINE DEDENT DEDENT return r NEW_LINE