Solve 26. Remove Duplicates from Sorted Array

This commit is contained in:
Kiril Kovachev 2024-03-08 16:51:55 +00:00
parent ed40cc2fd1
commit 8d4606ab95

View File

@ -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]