Skip to content

Commit

Permalink
Create 26-Remove-Duplicates-from-Sorted Array
Browse files Browse the repository at this point in the history
  • Loading branch information
lt77777 authored Apr 28, 2022
1 parent 01a2b36 commit c09339f
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions 26-Remove-Duplicates-from-Sorted Array
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
class Solution(object):
def removeDuplicates(self, nums):
"""
:type nums: List[int]
:rtype: int
"""
k = 0
i = 0
while i < len(nums):
val = nums[i]
while i + 1 < len(nums) and nums[i+1] == val:
nums.remove(val)
k += 1
i += 1
return len(nums)

0 comments on commit c09339f

Please sign in to comment.