天使不曾离开3,吞噬星空下载txt免费下载,华为荣耀v11
remove nth node from end of list(c++) 。given a linked list, remove then-th node from the end of list and return its head.
/**
* definition for singly-linked list.
* struct listnode {
* int val;
* listnode *next;
* listnode(int x) : val(x), next(null) {}
* };
*/
class solution {
public:
listnode* removenthfromend(listnode* head, int n)
{
if(head->next==null)
return null;
listnode *prev=head,*cur=head;
for(int i=0;i<>
cur=cur->next;
if(cur==null)
return head->next;
while(cur->next!=null)
{
cur=cur->next;
prev=prev->next;
}
prev->next=prev->next->next;
return head;
}
};
如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复
如何在没有core文件的情况下用dmesg+addr2line定位段错误
用QT制作3D点云显示器——QtDataVisualization
网友评论