Skip to content

Commit 9a0155f

Browse files
committed
remove dumplicates from sorted array
1 parent f77ac1c commit 9a0155f

File tree

1 file changed

+10
-0
lines changed
  • python/leetcode80_remove_duplicates_from_sorted_arrayii

1 file changed

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

0 commit comments

Comments
 (0)