# Code

• 提交Code
``````# Definition for singly-linked list.
# class ListNode:
#     def __init__(self, val=0, next=None):
#         self.val = val
#         self.next = next
class Solution:
def removeNthFromEnd(self, head: ListNode, n: int) -> ListNode:

while(n >= 0):
if(fast == None):
fast = fast.next
n -= 1

while( fast != None):
fast = fast.next
slow = slow.next

slow.next = slow.next.next

``````
• 完整Code
``````class ListNode:
def __init__(self, x):
self.val = x
self.next = None

class Solution:

tmp = listN
# 环状链表的构造
for m in range(1,head.__len__()):
listN = listN.next

print('-----------------------')

fast = tmp
slow = tmp

# if(n == 5):
#     tmp = tmp.next
#     return tmp

while (n >= 0):
# 用于判断是否为移除【正数】第一个数字的情况
if(fast == None):
tmp = tmp.next
return tmp
fast = fast.next
n -= 1
print('888888888888888888888888888888')

while (fast != None):
fast = fast.next
slow = slow.next

slow.next = slow.next.next
print('888888888888888888888888888888')
return tmp

S = Solution()
print("###################result###################")
print("result"+str(result))
print('-------------------------------------------')
while result != None:
print(result.val)
result = result.next
``````

### 要不赞赏一下?

 微信 支付宝 PayPal Bitcoin

``https://www.emperinter.info/2022/02/21/remove-nth-node-from-end-of-list/``

## 优惠码

 阿里云国际版 20美元 Vultr 10美元 搬瓦工 | Bandwagon 应该有折扣吧？ Just My Socks JMS9272283 【注意手动复制去跳转】 域名 | namesilo `emperinter`(1美元) 币安 币安