Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def removeDuplicates(l):
- n = len(l)
- i = 0
- j = 0
- while j < n:
- cur = l[j]
- while j < n and l[j] == cur:
- j += 1
- l[i] = cur
- i += 1
- toRemove = n - i
- for _ in range(toRemove):
- l.pop()
- l = [9, 9, 7, 7, 3, 1]
- removeDuplicates(l)
- print(*l)
- # Output: [9, 7, 3, 1]
Advertisement
Add Comment
Please, Sign In to add comment