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