You are viewing a single comment's thread. Return to all comments →
My output is right for each test cases but each node must be printed on new line ,how to do that?
My code:
Node* Delete(Node *head, int position) { // Complete this method Node * prev=head; Node *cn =head; int s=0; while(s!=position) { prev=cn; cn=cn->next; s++; }
if(position!=0) { prev->next=cn->next; cn=NULL; } else { head=head->next; } return head;
}
Seems like cookies are disabled on this browser, please enable them to open this website
Delete a Node
You are viewing a single comment's thread. Return to all comments →
My output is right for each test cases but each node must be printed on new line ,how to do that?
My code:
Node* Delete(Node *head, int position) { // Complete this method Node * prev=head; Node *cn =head; int s=0; while(s!=position) { prev=cn; cn=cn->next; s++; }
}