Delete duplicate-value nodes from a sorted linked list

  • + 0 comments

    Python 3

    def removeDuplicates(llist):
        # Write your code here
        head=llist
        while llist:
            nxt=llist.next
            if nxt and llist.data==nxt.data:
                llist.next=nxt.next
            else:
                llist=llist.next
        return head