/**
* Definition for singly-linked list.
* struct ListNode {
* int val;
* struct ListNode *next;
* };
*/
struct ListNode* removeElements(struct ListNode* head, int val) {
struct ListNode *p;
if(head == NULL)
return 0;
while(head != NULL && head->val == val)
head = head->next;
if(head == NULL)
return 0;
p = head;
while(p->next != NULL)
{
if(p->next->val == val)
p->next = p->next->next;
else
p = p->next;
}
return head;
}
LeetCode203移除链表元素C语言版
猜你喜欢
转载自blog.csdn.net/a_learning_boy/article/details/84260948
今日推荐
周排行