You are viewing a single comment's thread. Return to all comments →
Like this?
Node* RemoveDuplicates(Node *head) { if (!head) { return head; } Node* res = head; while (head->next) { if (head->next->data == head->data) { Node* toDelete = head->next; head->next = head->next->next; delete toDelete; } else { head = head->next; } } return res; }
Seems like cookies are disabled on this browser, please enable them to open this website
Delete duplicate-value nodes from a sorted linked list
You are viewing a single comment's thread. Return to all comments →
Like this?