Solution that beats 99.02% submissions.

  • 0
    def deleteDuplicates(self, head):
        :type head: ListNode
        :rtype: ListNode
        if head is None or is None:
            return head
        dummyHead = ListNode(0) = head
        prev = dummyHead
        node = head
        cur =
        while cur:
            if cur.val != node.val:
                if is cur:
                    prev = node
                    node =
           = cur
                    node = cur
            cur =
        if not is cur:
   = None

Log in to reply

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.