题目描述
blablabla
样例
blablabla
算法1
(暴力枚举) $O(n^2)$
blablabla
时间复杂度
参考文献
python 代码
# Definition for singly-linked list.
# class ListNode(object):
# def __init__(self, x):
# self.val = x
# self.next = None
class Solution(object):
def deleteDuplication(self, head):
"""
:type head: ListNode
:rtype: ListNode
"""
if head is None:
return None
dummy = ListNode(-1)
dummy.next = head
p = dummy
while p.next:
q = p.next
while q and q.val == p.next.val:
q = q.next
if q == p.next.next:
p = p.next
else:
p.next = q
return dummy.next