Skip to content

Instantly share code, notes, and snippets.

@mylons
Created March 3, 2019 16:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mylons/bd7881ef78c8d3a4c45d7d48ea33c7e0 to your computer and use it in GitHub Desktop.
Save mylons/bd7881ef78c8d3a4c45d7d48ea33c7e0 to your computer and use it in GitHub Desktop.
class Solution:
def removeDuplicates(self, nums: List[int]) -> int:
if len(nums) < 2: return len(nums)
length = 1
cur = 0
future = 1
while future < len(nums):
if nums[cur] == nums[future]:
nums[future] = 0
else:
cur = cur+1
nums[cur] = nums[future]
length += 1
future +=1
return length
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment