Skip to content

Commit d1f6b90

Browse files
Update binary_search.py
1 parent 45ecb09 commit d1f6b90

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

searches/binary_search.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -198,10 +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 any(
202-
sorted_collection[i] > sorted_collection[i + 1]
203-
for i in range(len(sorted_collection) - 1)
204-
):
201+
if all(a <= b for a, b in pairwise(sorted_collection)):
205202
raise ValueError("sorted_collection must be sorted in ascending order")
206203
left = 0
207204
right = len(sorted_collection) - 1

0 commit comments

Comments
 (0)