Skip to content

Instantly share code, notes, and snippets.

@pirate-kiiiing
Last active October 9, 2022 06:04
def partition(nums: List[int], l: int, r: int) -> int:
pivot, p = nums[r], r
i = l
while i < p:
if nums[i] > pivot:
nums[i], nums[p - 1] = nums[p - 1], nums[i]
nums[p], nums[p - 1] = nums[p - 1], nums[p]
i -= 1
p -= 1
i += 1
return p
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment