Skip to content

Commit

Permalink
参考lc27
Browse files Browse the repository at this point in the history
  • Loading branch information
rinwf committed Oct 4, 2018
1 parent adfb590 commit 74a2e9e
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions lc26. Remove Duplicates from Sorted Array.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
class Solution:
def removeDuplicates(self, nums):
"""
:type nums: List[int]
:rtype: int
"""
if not nums:
return 0
idx = 0
for i in range(len(nums)):
if nums[i] != nums[idx]:
idx += 1
nums[idx] = nums[i]

return idx + 1


nums = [1, 1, 2]
s = Solution()
print(s.removeDuplicates(nums))

0 comments on commit 74a2e9e

Please sign in to comment.