26. 删除排序数组中的重复项
2021-02-14 13:18
标签:color obj code img == 图片 dup 技术 mic 26. 删除排序数组中的重复项 标签:color obj code img == 图片 dup 技术 mic 原文地址:https://www.cnblogs.com/panweiwei/p/12723013.html 1 class Solution(object):
2 def removeDuplicates(self, nums):
3 """
4 :type nums: List[int]
5 :rtype: int
6 """
7 i = 0
8 while i :
9 if nums[i] != nums[i+1]:
10 i += 1
11 elif nums[i] == nums[i+1]:
12 nums.pop(i+1)
13 return len(nums)
14
15 if __name__ == ‘__main__‘:
16 solution = Solution()
17 print(solution.removeDuplicates(nums=[0, 0, 1, 1, 1, 2, 2, 3, 3, 4]))