Advertisement
Guest User

Remove Duplicates

a guest
Feb 26th, 2021
248
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.26 KB | None | 0 0
  1. def removeDuplicates(nums):
  2. if len(nums) < 2:
  3. return len(nums)
  4. slow, fast = 2, 2
  5.  
  6. while fast < len(nums):
  7. if nums[slow - 2] != nums[fast]:
  8. nums[slow] = nums[fast]
  9. slow += 1
  10. fast += 1
  11. return slow
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement