Skip to content

Instantly share code, notes, and snippets.

@gotraveltoworld
Last active April 16, 2018 16:56
Show Gist options
  • Save gotraveltoworld/dc8d352e994780006ce6eaefd7ac384c to your computer and use it in GitHub Desktop.
Save gotraveltoworld/dc8d352e994780006ce6eaefd7ac384c to your computer and use it in GitHub Desktop.
Python bisect practice
from bisect import bisect, insort
# Return the index.
def in_bisect(sorted_list, target_value):
i = bisect(sorted_list, target_value)
return i
# Return the new list.
def insert_by_bisect(sorted_list, target_value):
i = insort(sorted_list, target_value)
return sorted_list
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment