class Solution:

```
def removeNthFromEnd(self, head, n):
pre = head
length = 0
while(pre):
length += 1
pre = pre.next
if length == n :
return head.next
else:
cur = head
for i in range(length - n-1):
cur = cur.next
cur.next = cur.next.next
return head
```