Skip to content

Instantly share code, notes, and snippets.

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 Desolve/b2f59727e08875fcd99cafd47189da77 to your computer and use it in GitHub Desktop.
Save Desolve/b2f59727e08875fcd99cafd47189da77 to your computer and use it in GitHub Desktop.
0026 Remove Duplicates from Sorted Array
class Solution:
def removeDuplicates(self, nums):
if not nums: return 0
i, j = 0, 1
while j < len(nums):
if nums[i] != nums[j]:
i += 1
nums[i] = nums[j]
j += 1
return i + 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment