# -*- coding:utf-8 -*- # class ListNode: # def __init__(self, x): # self.val = x # self.next = None class Solution: def deleteDuplication(self, pHead): # write code here if not pHead or not pHead.next: return pHead pre = ListNode(0) head = pre pre.next = pHead cur = pHead nxt = pHead.next while nxt: if cur.val != nxt.val: if cur.next != nxt: pre.next = nxt cur = nxt else: pre = pre.next cur = cur.next nxt = nxt.next if cur.next: pre.next = None return head.next