Simple Python solution O(n)


  • 0
    class Solution(object):
        def deleteDuplicates(self, head):
            p = head
            if p is None: return p
            while p.next:
                if p.val==p.next.val:
                    p.next = p.next.next if p.next.next else None
                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.