class Solution(object):
def deleteDuplication(self, head):
dummy = ListNode(0)
dummy.next = head
tail = dummy # 头有可能没 要用dummy
while tail.next: # 因为用了tail.next的value, 所以while tail.next
nxt = tail.next
while(nxt and nxt.val == tail.next.val):
nxt = nxt.next
if tail.next.next == nxt: # 刚好隔了一个节点,没重复,不用删
tail = tail.next
else:
tail.next = nxt #用删
return dummy.next