We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 599353b commit 82b2f9eCopy full SHA for 82b2f9e
1 file changed
searches/jump_search.py
@@ -10,17 +10,14 @@
10
11
import math
12
from collections.abc import Sequence
13
-from typing import Any, Protocol, TypeVar
+from typing import Any, Protocol
14
15
16
class Comparable(Protocol):
17
def __lt__(self, other: Any, /) -> bool: ...
18
19
20
-T = TypeVar("T", bound=Comparable)
21
-
22
23
-def jump_search(arr: Sequence[T], item: T) -> int:
+def jump_search[T: Comparable](arr: Sequence[T], item: T) -> int:
24
"""
25
Python implementation of the jump search algorithm.
26
Return the index if the `item` is found, otherwise return -1.
0 commit comments