```
int countAndRemove(struct ListNode *node, int n){
if(!node->next) return n-1;
int rest = countAndRemove(node->next, n);
if(rest == 0) node->next = (node->next)->next;
return rest-1;
}
struct ListNode* removeNthFromEnd(struct ListNode* head, int n) {
return (countAndRemove(head, n) == 0)? head->next : head;
}
```