Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def partition(L):
- j = 0
- for i in range(1, len(L)):
- val = L[i]
- k = i
- while k > j and val < 0:
- L[k] = L[k - 1]
- k -= 1
- if j == k:
- j += 1
- L[k] = val
- L = [9, 2, -3, 1, 0, 0, -7, -6, 3, -5, 2]
- partition(L)
- # result: [-3, -7, -6, -5, 9, 2, 1, 0, 0, 3, 2]
Advertisement
Add Comment
Please, Sign In to add comment