Fast Python solution


  • 0
    C
    class Solution(object):
        def deleteDuplicates(self, head):
            """
            :type head: ListNode
            :rtype: ListNode
            """
            if head is None:
                return head
            node = head
            while node is not None:
                while node.next is not None and node.val == node.next.val:
                    node.next = node.next.next
                node = node.next
                if node is None:
                    break
            return head
    

Log in to reply
 

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