You are viewing a single comment's thread. Return to all comments →
My C++ deletion solution:
SinglyLinkedListNode* deleteNode(SinglyLinkedListNode* llist, int position) { SinglyLinkedListNode* ptr = llist; if (position == 0) { SinglyLinkedListNode* ret = llist->next; delete llist; return ret; } for (int i = 0; i < position-1; i++) { ptr = ptr->next; } SinglyLinkedListNode* remove = ptr->next; ptr->next = remove->next; delete remove; return llist; }
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 C++ deletion solution: