Skip to content

Commit 368eabd

Browse files
Update binary_search.py
1 parent d1f6b90 commit 368eabd

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

searches/binary_search.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ def binary_search(sorted_collection: list[int], item: int) -> int:
198198
>>> binary_search([0, 5, 7, 10, 15], 6)
199199
-1
200200
"""
201-
if all(a <= b for a, b in pairwise(sorted_collection)):
201+
if any(a > b for a, b in pairwise(sorted_collection)):
202202
raise ValueError("sorted_collection must be sorted in ascending order")
203203
left = 0
204204
right = len(sorted_collection) - 1

0 commit comments

Comments
 (0)