Skip to content

Commit effc727

Browse files
authored
Create Remove Duplicates from Sorted Array.py
1 parent 8088d9f commit effc727

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#26. Remove Duplicates from Sorted Array
2+
class Solution:
3+
def removeDuplicates(self, nums: List[int]) -> int:
4+
i = 0
5+
6+
for num in nums:
7+
if i < 1 or num > nums[i - 1]:
8+
nums[i] = num
9+
i += 1
10+
11+
return i

0 commit comments

Comments
 (0)