26. 删除排序数组中的重复项
2021-02-09 22:16
标签:code 排序数组 rem elf http span ret ica img 26. 删除排序数组中的重复项 标签:code 排序数组 rem elf http span ret ica img 原文地址:https://www.cnblogs.com/panweiwei/p/12748672.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
16 if __name__ == ‘__main__‘:
17 solution = Solution()
18 print(solution.removeDuplicates(nums=[0, 0, 1, 1, 1, 2, 2, 3, 3, 4]))
上一篇:python学习37——课后练习