网站建设收费标准,wordpress 邮件回复,寄生虫做网站流量,电商网站建设费用预算目录 1.解题思路2.代码实现 1.解题思路
利用双指针#xff0c;开辟一个新的头结点并依次向头结点尾插不为val的结点如果遇到值为val的结点就跳过并释放掉
2.代码实现
struct ListNode* removeElements(struct ListNode* head, int val)
{ if(headNULL)return NULL;struct … 目录 1.解题思路2.代码实现 1.解题思路
利用双指针开辟一个新的头结点并依次向头结点尾插不为val的结点如果遇到值为val的结点就跳过并释放掉
2.代码实现
struct ListNode* removeElements(struct ListNode* head, int val)
{ if(headNULL)return NULL;struct ListNode* newheadNULL;struct ListNode*tailNULL;struct ListNode* curhead;while(cur){if(cur-valval){struct ListNode*pscur;curcur-next; free(ps); psNULL;}
else
{if(tailNULL){newheadcur;tailcur;}else{tail-nextcur;tailtail-next;}curcur-next;
}}if(tail!NULL)
tail-nextNULL;
return newhead;}结尾今天的分享到此结束喜欢的朋友如果感觉有帮助可以点赞三连支持咱们共同进步!