Skip to content

Instantly share code, notes, and snippets.

@EfrainReyes
Last active November 11, 2022 01:17
Show Gist options
  • Save EfrainReyes/e13b9873a86fd03912f9c4c14c55a4f6 to your computer and use it in GitHub Desktop.
Save EfrainReyes/e13b9873a86fd03912f9c4c14c55a4f6 to your computer and use it in GitHub Desktop.
26. Remove Duplicates from Sorted Array (Python)
class Solution:
def removeDuplicates(self, nums: List[int]) -> int:
if len(nums) == 1:
return 1
non_dupes_ptr = 1
for num in nums:
if nums[non_dupes_ptr - 1] < num:
nums[non_dupes_ptr] = num
non_dupes_ptr += 1
return non_dupes_ptr
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment