Created
June 9, 2018 09:54
-
-
Save whiledoing/f184179a9c820391cb2da06a69e0aa44 to your computer and use it in GitHub Desktop.
[python-bisect-left] binary left search implmentation #python #algorithm
This file contains 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 bisect_left(data, v): | |
left, right = 0, len(data) | |
while left < right: | |
mid = (left+right)//2 | |
if v <= data[mid]: | |
right = mid | |
else: | |
left = mid+1 | |
return right |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment