Skip to content

Instantly share code, notes, and snippets.

@jason-curtis
Created January 21, 2020 23:21
Show Gist options
  • Save jason-curtis/4aaf8c7bfb46490efcb737de5995bf38 to your computer and use it in GitHub Desktop.
Save jason-curtis/4aaf8c7bfb46490efcb737de5995bf38 to your computer and use it in GitHub Desktop.
bisect example
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