Created
January 21, 2020 23:21
-
-
Save jason-curtis/4aaf8c7bfb46490efcb737de5995bf38 to your computer and use it in GitHub Desktop.
bisect example
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
import bisect | |
def value_is_present(list_, value): | |
insertion_point = bisect.bisect_left(list_, value) | |
return ( | |
# If value is larger than all values in list_, it will be len(list_) | |
insertion_point < len(list_) | |
and arr[insertion_point] == value | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment