Skip to content

Commit cfabf16

Browse files
committedNov 18, 2023
26_remove-duplicates-from-sorted-array
1 parent 5f6d83e commit cfabf16

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed
 
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
class Solution:
2+
def removeDuplicates(self, nums: List[int]) -> int:
3+
result = len(nums)
4+
for i in range(len(nums) - 1, 0, -1):
5+
if nums[i] == nums[i-1]:
6+
del nums[i]
7+
result -= 1
8+
9+
return result

0 commit comments

Comments
 (0)
Please sign in to comment.