https://leetcode-cn.com/problems/remove-nth-node-from-end-of-list/
思路:先过滤n个节点
ListNode* removeNthFromEnd(ListNode* head, int n) {
ListNode* res = new ListNode();
ListNode* ret;
ret = res;
if (head == NULL) {
return res;
}
ListNode *pri = new ListNode();
pri->next = head;
res->next = head;
while(n) {
pri = pri->next;
n -= 1;
}
while(pri->next) {
pri = pri->next;
res = res->next;
}
res->next = res->next->next;
return ret->next;
}