Skip to content

Commit cf9137b

Browse files
authored
Refactor jump_search to check for empty array first
1 parent 78923a4 commit cf9137b

1 file changed

Lines changed: 2 additions & 3 deletions

File tree

searches/jump_search.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,9 @@ def jump_search[T: Comparable](arr: Sequence[T], item: T) -> int:
3636
>>> jump_search([], 1)
3737
-1
3838
"""
39-
40-
arr_size = len(arr)
41-
if arr_size == 0:
39+
if not arr:
4240
return -1
41+
arr_size = len(arr)
4342

4443
block_size = int(math.sqrt(arr_size))
4544

0 commit comments

Comments
 (0)