Skip to content

Instantly share code, notes, and snippets.

@mdpabel
Created April 2, 2022 07:21
Show Gist options
  • Save mdpabel/1bd153ec9e84de9c518fad3c83bce30e to your computer and use it in GitHub Desktop.
Save mdpabel/1bd153ec9e84de9c518fad3c83bce30e to your computer and use it in GitHub Desktop.
def removeDuplicates(self, nums: List[int]) -> int:
k = 0
n = len(nums)
for i in range(1, n):
if nums[i] != nums[i - 1]:
nums[k] = nums[i - 1]
k += 1
nums[k] = nums[n - 1]
k += 1
return k
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment