Skip to content

Commit 7199a35

Browse files
authored
Update k-closest-points-to-origin.py
1 parent 09a4252 commit 7199a35

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

Python/k-closest-points-to-origin.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@ def PartitionAroundPivot(left, right, pivot_idx, nums, compare):
3131
while left <= right:
3232
pivot_idx = randint(left, right)
3333
new_pivot_idx = PartitionAroundPivot(left, right, pivot_idx, nums, compare)
34-
if new_pivot_idx == k - 1:
34+
if new_pivot_idx == k:
3535
return
36-
elif new_pivot_idx > k - 1:
36+
elif new_pivot_idx > k:
3737
right = new_pivot_idx - 1
38-
else: # new_pivot_idx < k - 1.
38+
else: # new_pivot_idx < k.
3939
left = new_pivot_idx + 1
4040

4141
kthElement(points, K, lambda a, b: dist(a) < dist(b))

0 commit comments

Comments
 (0)