text: # 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:
          cur = head
          while cur:
              while cur.next and cur.next.val == cur.val:
                  cur.next = cur.next.next
              cur = cur.next
          return head