struct ListNode* deleteNode(struct ListNode* head, int n, int i){
if (head == NULL) return NULL;
if (i == n) return head->next;//找到了
head->next = deleteNode(head->next, n, i+1);
return head;
}
struct ListNode* removeNthFromEnd(struct ListNode* head, int n){
if (head == NULL || n < 1) return head;
struct ListNode *p = head;
int nodenum = 0;
for (; p; p = p->next, ++nodenum);
if (n > nodenum) return head; //大于所有结点数
return deleteNode(head, nodenum-n, 0);
}