#-*- coding: UTF-8 -*-
class Solution(object):
def removeDuplicates(self, nums):
"""
:type nums: List[int]
:rtype: int
"""
if len(nums)<=1:return len(nums)
pre=0;next=1
while True:
if nums[next]==nums[pre]:
del nums[next]
else:
pre=next
next+=1
if next>=len(nums):break
return len(nums)
# sorted(set(nums),key=nums.index)
# print nums
sol=Solution()
print sol.removeDuplicates([1,1,2,2,4,4,5,5])
相关文章
- 【leetcode❤python】26. Remove Duplicates from Sorted Array
- Remove Duplicates from Sorted List @LeetCode
- 【数组】Remove Duplicates from Sorted Array II
- 【Leetcode】【Medium】Remove Duplicates from Sorted Array II
- 【LeetCode】Remove Duplicates from Sorted Array(删除排序数组中的重复项)
- 【leetcode】Remove Duplicates from Sorted List
- 【leetcode】Remove Duplicates from Sorted Array I & II(middle)
- 【26】Remove Duplicates from Sorted Array
- 【leetcode】 Remove Duplicates from Sorted List
- 算法题丨Remove Duplicates from Sorted Array II