Fix index off by 1
This commit is contained in:
parent
5c43ffb602
commit
022533dc4a
|
@ -7,9 +7,9 @@ def qselect(i, xs):
|
|||
left = [x for x in xs if x < pivot]
|
||||
right = [x for x in xs if x >= pivot]
|
||||
|
||||
if i > len(left):
|
||||
if i > len(left) + 1:
|
||||
return qselect(i - len(left) - 1, right)
|
||||
elif i == len(left):
|
||||
elif i == len(left) + 1:
|
||||
return pivot
|
||||
else:
|
||||
return qselect(i, left)
|
||||
|
|
Loading…
Reference in New Issue
Block a user