# Definition for singly-linked list. # class ListNode: # def __init__(self, x): # self.val = x # self.next = None class Solution: def deleteDuplicates(self, head: ListNode) -> ListNode: node=head while node and node.next: if node.val==node.next.val: new=node.next.next while new: if not new: break if new.val==node.val: new=new.next else: break node.next=new node=node.next return head