Merge pull request #1925 from ZerenZhang2022/patch-11

Update 0019.删除链表的倒数第N个节点.md
This commit is contained in:
程序员Carl 2023-03-08 10:08:20 +08:00 committed by GitHub
commit 6f30807f78
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 2 deletions

View File

@ -129,10 +129,10 @@ class Solution:
head_dummy.next = head
slow, fast = head_dummy, head_dummy
while(n!=0): #fast先往前走n步
while(n>=0): #fast先往前走n+1步
fast = fast.next
n -= 1
while(fast.next!=None):
while(fast!=None):
slow = slow.next
fast = fast.next
#fast 走到结尾后slow的下一个节点为倒数第N个节点