[Python] simplified


  • 0
    S
    def deleteDuplicates(self, head):
            """
            :type head: ListNode
            :rtype: ListNode
            """
            p = head
            while p:
                if p.next and p.next.val == p.val:
                    p.next = p.next.next
                else:
                    p = p.next
            return head
    

Log in to reply
 

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