python 이분탐색 함수 bisect Posted on 2021-10-05 Edited on 2021-10-04 In Language , Python Views: bisect 라이브러리bisect : 정렬된 배열을 유지하면서 특정 값을 배열에 추가할 때, 몇 번째 인덱스에 넣어야하는지 반환하는 함수 123456from bisect import bisect_left, bisect_rightnums = [0,1,2,3,4,5,6,7,8,9]n = 5print(bisect_left(nums, n)) >>> 5print(bisect_right(nums, n)) >>> 6 bisect_left(literable, value) : 왼쪽 인덱스를 구하기 bisect_right(literable, value) : 오른쪽 인덱스를 구하기