/**
* Definition for singly-linked list.
* struct ListNode {
* int val;
* struct ListNode *next;
* };
*/
//用差值找到倒数第N个
struct ListNode* removeNthFromEnd(struct ListNode* head, int n){
struct ListNode *dummyhead =(struct ListNode *)malloc(sizeof(struct ListNode));
dummyhead->next=head;
struct ListNode *fast =dummyhead;
struct ListNode *slow=dummyhead;
struct ListNode *tmp =NULL;
int i=0;
for(i;i<=n;i++)
{
fast=fast->next;
}
while(fast!=NULL)
{
fast=fast->next;
slow=slow->next;
}
tmp=slow->next;
slow->next=tmp->next;
free(tmp);
return dummyhead->next;