mirror of
https://github.com/youngyangyang04/leetcode-master.git
synced 2025-07-07 15:45:40 +08:00
Update 0019.删除链表的倒数第N个节点.md,修复 CPP 解法代码中的内存泄漏
This commit is contained in:
@ -75,7 +75,11 @@ public:
|
|||||||
fast = fast->next;
|
fast = fast->next;
|
||||||
slow = slow->next;
|
slow = slow->next;
|
||||||
}
|
}
|
||||||
slow->next = slow->next->next;
|
|
||||||
|
ListNode *nth = slow->next;
|
||||||
|
slow->next = nth->next;
|
||||||
|
delete nth;
|
||||||
|
|
||||||
return dummyHead->next;
|
return dummyHead->next;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user