Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions searches/binary_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ def bisect_left(
>>> bisect_left([1, 2, 2, 2, 4], 2)
1
"""
if lo < 0:
raise ValueError("lo must be non-negative")

if hi < 0:
hi = len(sorted_collection)

Expand Down Expand Up @@ -96,6 +99,9 @@ def bisect_right(
>>> bisect_right([1, 2, 2, 2, 4], 2)
4
"""
if lo < 0:
raise ValueError("lo must be non-negative")

if hi < 0:
hi = len(sorted_collection)

Expand Down
Loading