Chapter 2: 이진 탐색
내용 정리
선형 스캔
이진 탐색 알고리즘
def binary_search(array: list[int], target: int) -> int: start, end = 0, len(array) - 1 while start <= end: mid = (start + end) // 2 if array[mid] == target: return mid elif array[mid] < target: start = mid + 1 else: end = mid - 1 return -1- Time ComplexitySpace Complexity
생각
Last updated