标签:用户 nod span inf info 链表 list self color
用列表完成!!!!
# Definition for singly-linked list. # class ListNode: # def __init__(self, x): # self.val = x # self.next = None class Solution: def removeNthFromEnd(self, head: ListNode, n: int) -> ListNode: if head.next==None and n==1: return a=[] while head: a.append(head.val) head=head.next #print(a) #print(len(a)) a.pop(len(a)-n) head=ListNode(a[0]) p=head for i in range(1,len(a)): p.next=ListNode(a[i]) p=p.next return head
标签:用户 nod span inf info 链表 list self color
原文地址:https://www.cnblogs.com/taoyuxin/p/11729556.html