Created
February 13, 2019 14:50
-
-
Save saikpr/91521a3eb888ed3e3e702c914351dbde to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def firstBadVersion(arr, target, low, high): | |
""" | |
:type n: int | |
:rtype: int | |
""" | |
while low!=high: | |
mid = (high + low)/2 | |
if arr[mid]>=target: | |
high = mid | |
else: | |
low = mid +1 | |
return int(low) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment