Clean Python Solution


  • 0
    C

    Look for a valid next node for the current node

    class Solution(object):
        def deleteDuplicates(self, head):
            curr = head
    
            while curr:
                next = curr.next
                while next and next.val == curr.val:
                    next = next.next
    
                curr.next = next
                curr = curr.next
    
            return head
    

Log in to reply
 

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