python two pointers solution


  • 0
    G
    class Solution(object):
        def deleteDuplicates(self,head):
            slow,fast=head,head
            while fast:
                if slow.val==fast.val:
                    slow.next=fast.next
                else:
                    slow=fast
                fast=fast.next
            return head
    

Log in to reply
 

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