Advertisement
Guest User

Remove Duplicates

a guest
Feb 26th, 2021
126
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement