for efficient searching , use binary search .
while ( start <= end ) : NEW_LINE INDENT mid = ( start + end ) // 2 NEW_LINE val = func ( a , b , c , mid ) NEW_LINE if ( val == k ) : NEW_LINE INDENT ans = mid NEW_LINE break NEW_LINE DEDENT elif ( val > k ) : NEW_LINE INDENT end = mid - 1 NEW_LINE DEDENT else : NEW_LINE INDENT start = mid + 1 NEW_LINE DEDENT DEDENT return ans ; NEW_LINE