别人方法: class Solution: def deleteDuplication(self, pHead): # write code here ret = ListNode(0) real = ret pre = ret cur = pHead while cur: if (cur.val != pre.val or pre == real) and (not cur.next or cur.val != cur.next.val): real.next = cur real = real.next pre = cur cur = cur.next real.next = None return ret.nex 自己方法: class Solution: def deleteDuplication(self, pHead): # write code here num = [] while pHead: num.append(pHead.val) pHead = pHead.next num = list(filter(lambda c:num.count(c)==1,num)) ret = ListNode(0) res = ret for i in num: ret.next = ListNode(i) ret = ret.next ret.next = None return res.next