双指针法
struct ListNode* removeNthFromEnd(struct ListNode* head, int n) {
struct ListNode* dummy = (struct ListNode*)malloc(sizeof(struct ListNode));
dummy->next = head;
struct ListNode* cur1 = dummy;
struct ListNode* cur2 = dummy;
while (n--) {
cur1 = cur1->next;
}
while (cur1->next) {
cur1 = cur1->next;
cur2 = cur2->next;
}
struct ListNode* tmp = cur2->next;
cur2->next = cur2->next->next;
free(tmp);
struct ListNode* retList = dummy->next;
free(dummy);
return retList;
}