Leetcode/python/remove_duplicates_from_sorted_array.py

9 lines
287 B
Python
Raw Normal View History

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]
2024-03-08 16:56:44 +00:00
return len(nums)