ListNode* removeNthFromEnd(ListNode* head, int n) {
if(!head->next)return NULL;
ListNode* p=head,*q=head;
for(int i=0;i<n;i++)q=q->next;
if(!q)return head->next;
while(q->next)
{
q=q->next;
p=p->next;
}
p->next=p->next->next;
return head;
}
Leetcode 19
猜你喜欢
转载自blog.csdn.net/TempterCyn/article/details/82902733
今日推荐
周排行