Skip to content

Commit c2aafb4

Browse files
committed
feat: adds remove_duplicates_sorted_array exercise
1 parent 11bad6f commit c2aafb4

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

remove_duplicates_sorted_array.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
from typing import List
2+
3+
4+
class Solution:
5+
def removeDuplicates(self, nums: List[int]) -> int:
6+
cur = 0
7+
last = None
8+
9+
for n in nums:
10+
if n != last:
11+
last = n
12+
nums[cur] = n
13+
cur += 1
14+
15+
return cur

0 commit comments

Comments
 (0)