"""
Definition of ListNode
class ListNode(object):
def __init__(self, val, next=None):
self.val = val
self.next = next
"""
class Solution:
"""
@param head: head is the head of the linked list
@return: head of the linked list
"""
def deleteDuplicates(self, head):
dummy = head
pre = head
val = None
while head and head.next:
while head.next != None and head.val == head.next.val:
val = head.val
temp = head.next
head.next = temp.next
if head.val == val:
print(head.val)
if head != pre:
pre.next = head.next
head = pre.next
else:
pre = pre.next
head = head.next
dummy = head
else:
pre = head
head = head.next
return dummy