Shortened code (#3855)

This commit is contained in:
jbaenaxd
2020-11-01 08:38:11 +01:00
committed by GitHub
parent a538989939
commit 1f65007456

View File

@ -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)