처음에 짠 코드 n, m = list(map(int, input().split())) arr = list(map(int, input().split())) start = arr[0] end = arr[-1] count = 0 while start m: end = mid - 1 else: start = mid + 1 print(count) BS를 적용한 코드 from bisect import bisect_left, bisect_right def count_by_range(array, left_value, right_value): right_index = bisect_right(array, right_value) left_index = bisect_left(array, left_value) return rig..
[이취코] 정렬된 수열에서 특정 수의 개수 구하기 (Python)
처음에 짠 코드 n, m = list(map(int, input().split())) arr = list(map(int, input().split())) start = arr[0] end = arr[-1] count = 0 while start m: end = mid - 1 else: start = mid + 1 print(count) BS를 적용한 코드 from bisect import bisect_left, bisect_right def count_by_range(array, left_value, right_value): right_index = bisect_right(array, right_value) left_index = bisect_left(array, left_value) return rig..
2024.03.06