找到一种十分简洁的写法
# Definition for singly-linked list.
# class ListNode(object):
# def __init__(self, x):
# self.val = x
# self.next = None
class Solution(object):
def filterList(self, head):
"""
:type head: ListNode
:rtype: ListNode
"""
a = [0] * 10010
p = head
while p and p.next:
a[abs(p.val)] += 1
while p.next and a[abs(p.next.val)] == 1:
p.next = p.next.next
p = p.next
return head