Update 0019.删除链表的倒数第N个节点.md

This commit is contained in:
程序员Carl
2022-10-12 12:32:40 +08:00
committed by GitHub
parent 6476576fa7
commit 35b28d3768

View File

@ -75,10 +75,11 @@ public:
fast = fast->next; fast = fast->next;
slow = slow->next; slow = slow->next;
} }
slow->next = slow->next->next;
ListNode *nth = slow->next; // ListNode *tmp = slow->next; C++释放内存的逻辑
slow->next = nth->next; // slow->next = tmp->next;
delete nth; // delete nth;
return dummyHead->next; return dummyHead->next;
} }