class ListNode(object):
def __init__(self,x):
self.val=x
self.next=None
class Solution(object):
def deleteDuplication(self,head):
dummy=ListNode(None)
dummy.next=head
pt0=head
#快指针
pt1=dummy
#慢指针
pre=None
while pt0:
if pt0.next==None:
if pt0.val==pre:
pt1.next=None
else:
pt1.next=pt0
break
if pt0.val!=pre and pt0.val!=pt0.next.val:
#延伸
pt1.next=pt0
pt1=pt1.next
pre=pt0.val
pt0=pt0.next
return dummy.next