Skip to content

Instantly share code, notes, and snippets.

@GINK03
Created August 5, 2018 09:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save GINK03/078e1e282299eb2f89f35a8206f17036 to your computer and use it in GitHub Desktop.
Save GINK03/078e1e282299eb2f89f35a8206f17036 to your computer and use it in GitHub Desktop.
bisect

木系のアルゴリズム

bisect

O(n)で順序をソート維持しながらソートできる

ex

こんな感じ

insert indexが帰ってくる

>>> from bisect import bisect
>>> a = [1, 4, 8, 12]
>>> a
[1, 4, 8, 12]
>>> bisect(a, 10)
3 
>>> bisect(a, 2)
1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment