# class ListNode:
# def __init__(self, x):
# self.val = x
# self.next = None
#
#
# @param head ListNode类
# @param n int整型
# @return ListNode类
#
class Solution:
def removeNthFromEnd(self , head , n ):
# write code here
L, node = 0, head
while node:
L += 1
node = node.next
dummy = ListNode(None)
dummy.next = head
cur = dummy
for i in range(L-n):
cur = cur.next
cur.next = cur.next.next
return dummy.next