mirror of
https://hub.njuu.cf/TheAlgorithms/Python.git
synced 2023-10-11 13:06:12 +08:00
Shortened code (#3855)
This commit is contained in:
parent
a538989939
commit
1f65007456
@ -44,8 +44,7 @@ def quick_select(items: list, index: int):
|
||||
if index >= len(items) or index < 0:
|
||||
return None
|
||||
|
||||
pivot = random.randint(0, len(items) - 1)
|
||||
pivot = items[pivot]
|
||||
pivot = items[random.randint(0, len(items) - 1)]
|
||||
count = 0
|
||||
smaller, equal, larger = _partition(items, pivot)
|
||||
count = len(equal)
|
||||
|
Loading…
Reference in New Issue
Block a user