Skip to content

Commit 45bd3c3

Browse files
authored
Update maximize-sum-of-array-after-k-negations.py
1 parent 99915ba commit 45bd3c3

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

Python/maximize-sum-of-array-after-k-negations.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@ def PartitionAroundPivot(left, right, pivot_idx, nums, compare):
2828
while left <= right:
2929
pivot_idx = random.randint(left, right)
3030
new_pivot_idx = PartitionAroundPivot(left, right, pivot_idx, nums, compare)
31-
if new_pivot_idx == k - 1:
31+
if new_pivot_idx == k:
3232
return
33-
elif new_pivot_idx > k - 1:
33+
elif new_pivot_idx > k:
3434
right = new_pivot_idx - 1
35-
else: # new_pivot_idx < k - 1.
35+
else: # new_pivot_idx < k.
3636
left = new_pivot_idx + 1
3737

3838
kthElement(A, K, lambda a, b: a < b)

0 commit comments

Comments
 (0)