mirror of
https://github.com/youngyangyang04/leetcode-master.git
synced 2025-07-06 23:28:29 +08:00
Merge pull request #1925 from ZerenZhang2022/patch-11
Update 0019.删除链表的倒数第N个节点.md
This commit is contained in:
@ -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个节点
|
||||
|
Reference in New Issue
Block a user