We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 0fb0a47 commit 0c53394Copy full SHA for 0c53394
Algorithms/Easy/26_RemoveDuplicatesFromSortedArray/Solution.py
@@ -0,0 +1,15 @@
1
+class Solution:
2
+ def removeDuplicates(self, nums: List[int]) -> int:
3
+ # go through the array,
4
+ # if nth item and (n+1)th item match, pop nth item, but don't forward
5
+ # otherwise go forward
6
+
7
+ i = 1
8
+ while i<len(nums):
9
+ if nums[i-1] == nums[i]:
10
+ nums.pop(i-1)
11
+ else:
12
+ i += 1
13
14
15
+ return len(nums)
0 commit comments