mirror of
https://github.com/TheAlgorithms/Python.git
synced 2025-07-05 17:34:49 +08:00
Shortened code (#3855)
This commit is contained in:
@ -44,8 +44,7 @@ def quick_select(items: list, index: int):
|
|||||||
if index >= len(items) or index < 0:
|
if index >= len(items) or index < 0:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
pivot = random.randint(0, len(items) - 1)
|
pivot = items[random.randint(0, len(items) - 1)]
|
||||||
pivot = items[pivot]
|
|
||||||
count = 0
|
count = 0
|
||||||
smaller, equal, larger = _partition(items, pivot)
|
smaller, equal, larger = _partition(items, pivot)
|
||||||
count = len(equal)
|
count = len(equal)
|
||||||
|
Reference in New Issue
Block a user