其他分享
首页 > 其他分享> > 26. 删除排序数组中的重复项

26. 删除排序数组中的重复项

作者:互联网

 

 

 

 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 < len(nums) - 1:
 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]))

 

标签:__,26,nums,int,Solution,len,数组,removeDuplicates,排序
来源: https://www.cnblogs.com/panweiwei/p/12748672.html