clean python solution involving dummy node

  • 0
    class Solution(object):
        def deleteDuplicates(self, head):
            :type head: ListNode
            :rtype: ListNode
            dummy = ListNode(-1)
   = head
            prev, curr = dummy,
            while curr:
                if and curr.val ==
                    val_to_rem = curr.val
                    while curr and curr.val == val_to_rem:
                        curr =
           = curr
                    prev, curr = curr,

Log in to reply

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