#-*- 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])
相关文章
- 02-24leetcode — remove-duplicates-from-sorted-list
- 02-24LeetCode-Easy-Remove Duplicates from Sorted Array
- 02-24【leetcode】Remove Duplicates from Sorted List (easy)
- 02-24LeetCode OJ:Remove Duplicates from Sorted List II(链表去重II)
- 02-24【leetcode❤python】83. Remove Duplicates from Sorted List
- 02-24【leetcode❤python】26. Remove Duplicates from Sorted Array
- 02-24leetcode83_Remove Duplicates from Sorted List
- 02-24LeetCode之“链表”:Remove Duplicates from Sorted List && Remove Duplicates from Sorted List II
- 02-24LeetCode OJ 80. Remove Duplicates from Sorted Array II
- 02-24Remove Duplicates from Sorted Array [LeetCode]