Fix exponential search for empty collections (#15362)

Co-authored-by: = <=>
This commit is contained in:
Dhaylight1
2026-09-18 02:59:36 +02:00
committed by GitHub
co-authored by = <=>
parent eb06d0d81b
commit 00fab97a29
+2
View File
@@ -85,6 +85,8 @@ def exponential_search(sorted_collection: list[int], item: int) -> int:
if list(sorted_collection) != sorted(sorted_collection):
raise ValueError("sorted_collection must be sorted in ascending order")
if not sorted_collection:
return -1
if sorted_collection[0] == item:
return 0