The helper() function is the part doing the recursion.

```
class Solution {
public:
ListNode* removeNthFromEnd(ListNode* head, int n) {
return helper(NULL, head, n);
}
ListNode* helper(ListNode* prev, ListNode* curr, int& n) {
if (curr == NULL) return NULL;
helper(curr, curr->next, n);
n--;
if (n==0 && prev==NULL) {free(curr); return curr->next;}
else if (n==0 && prev!=NULL) {free(curr); prev->next = curr->next;}
return curr;
}
};
```