mirror of
https://github.com/youngyangyang04/leetcode-master.git
synced 2025-07-08 00:43:04 +08:00
更正 0019 删除链表中倒数第N个节点 JavaScript 代码
This commit is contained in:
@ -173,8 +173,7 @@ var removeNthFromEnd = function(head, n) {
|
|||||||
let ret = new ListNode(0, head),
|
let ret = new ListNode(0, head),
|
||||||
slow = fast = ret;
|
slow = fast = ret;
|
||||||
while(n--) fast = fast.next;
|
while(n--) fast = fast.next;
|
||||||
if(!fast) return ret.next;
|
while (fast.next !== null) {
|
||||||
while (fast.next) {
|
|
||||||
fast = fast.next;
|
fast = fast.next;
|
||||||
slow = slow.next
|
slow = slow.next
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user