```
def removeNthFromEnd(self, head, n):
node = head;
i = 1
d={}
while node.next!=None:
d[i] = node
i +=1
node = node.next
d[i] = node
length = max(d.keys())
if n ==1:
if length >1:
d[length-1].next = None
return d[1]
else:
return None
elif n == length:
return d[2]
else:
d[length-n].next = d[length-n+2]
return d[1]
```