Merge pull request #926 from Jerry-306/patch-46

更正 0019 删除链表中倒数第N个节点 JavaScript 代码
This commit is contained in:
程序员Carl 2021-12-06 09:33:28 +08:00 committed by GitHub
commit e146d737bc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 2 deletions

View File

@ -173,8 +173,7 @@ var removeNthFromEnd = function(head, n) {
let ret = new ListNode(0, head),
slow = fast = ret;
while(n--) fast = fast.next;
if(!fast) return ret.next;
while (fast.next) {
while (fast.next !== null) {
fast = fast.next;
slow = slow.next
};