Iterative python solution beats 99.8%


  • 0
    C
    class Solution(object):
        def deleteDuplicates(self, head):
            """
            :type head: ListNode
            :rtype: ListNode
            """
            current = head
            while current and current.next: 
                if current.val == current.next.val:
                    current.next = current.next.next
                else:
                    current = current.next
            return head
            
    

Log in to reply
 

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