您的位置:首页 > Web前端 > Node.js

2.3 Delete Middle Node

2015-10-27 03:48 507 查看
The question requires that: we are not given access to the head of linked list. We only have access to the node which is going to be deleted.

So the solution is simply copying next node to the node which is going to be deleted.

void deleteNode(ListNode* node) {
ListNode* tmp = node->next;
*node = *node->next;
delete tmp;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  LinkedList