Run time error for deleteduplicates


  • 0
    A

    Node *deleteDuplicates(Node *head){

        assert(head);
        Node *next_next;
        Node *cur = head;
        while (cur->next){
            while(cur->val==cur->next->val){
            	if (!cur->next->next)	{delete cur->next; cur->next=NULL; return head;}
            	next_next=cur->next->next;
            	delete cur->next;
            	cur->next=next_next;
            }
        	cur=cur->next;
        }
        return head;
    

    }


Log in to reply
 

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