Solve 26. Remove Duplicates from Sorted Array
This commit is contained in:
parent
ed40cc2fd1
commit
8d4606ab95
8
python/remove_duplicates_from_sorted_array.py
Normal file
8
python/remove_duplicates_from_sorted_array.py
Normal 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]
|
Loading…
Reference in New Issue
Block a user