Update 0019.删除链表的倒数第N个节点.md,修复 CPP 解法代码中的内存泄漏

This commit is contained in:
wyzzoo
2022-10-06 00:17:27 +08:00
committed by GitHub
parent 9ea9473907
commit 6476576fa7

View File

@ -75,7 +75,11 @@ public:
fast = fast->next;
slow = slow->next;
}
slow->next = slow->next->next;
ListNode *nth = slow->next;
slow->next = nth->next;
delete nth;
return dummyHead->next;
}
};