```
class Solution {
public:
ListNode *removeNthFromEnd(ListNode *head, int n) {
if(!head)
return 0;
vector<ListNode*> list;
ListNode* curr = head;
int i = 0;
list[i] = curr;
while(curr->next){
i++;
curr = curr->next;
list[i] = curr;
}
i++;
if((i - n) == 0){
return head->next;
}
list.at(i - n - 1)->next = list.at(i - n)->next;
return head;
}
};
```