# class ListNode:
# def __init__(self, x):
# self.val = x
# self.next = None
#
#
# @param head ListNode类
# @return ListNode类
#
class Solution:
def deleteDuplicates(self , head ):
# write code here
new_head = ListNode(-1)
new_tail = new_head
temp = head
while temp:
if temp.next and temp.next.val == temp.val:
value = temp.val
while temp and temp.val==value:
temp = temp.next
else:
new_temp = temp.next
new_tail.next = temp
new_tail = new_tail.next
new_tail.next = None
temp = new_temp
return new_head.next