diff --git a/python/remove_duplicates_from_sorted_array.py b/python/remove_duplicates_from_sorted_array.py new file mode 100644 index 0000000..117e87c --- /dev/null +++ b/python/remove_duplicates_from_sorted_array.py @@ -0,0 +1,8 @@ +class Solution: + def removeDuplicates(self, nums: List[int]) -> int: + current = nums[-1] + 1 + for i in range(len(nums)-1, -1, -1): + if nums[i] == current: + del nums[i] + else: + current = nums[i]