class Solution:
# @param {ListNode} head
# @param {integer} n
# @return {ListNode}
def removeNthFromEnd(self, head, n):
dummy=ListNode(0); dummy.next=head
p1=p2=dummy
for i in range(n): p1 = p1.next
while p1.next:
p1 = p1.next; p2 = p2.next
p2.next = p2.next.next
return dummy.next
Leetcode19 Remove Nth Node From End of List
最新推荐文章于 2022-10-29 13:05:33 发布