###### leetcode-203 Remove Linked List Elements

Remove all elements from a linked list of integers that have value val.

Example
Given: 1 –> 2 –> 6 –> 3 –> 4 –> 5 –> 6, val = 6
Return: 1 –> 2 –> 3 –> 4 –> 5

/**
* struct ListNode {
*     int val;
*     ListNode *next;
*     ListNode(int x) : val(x), next(NULL) {}
* };
*/
class Solution {
public:
ListNode* removeElements(ListNode* head, int val) {
ListNode *p, *q;
while( q!=NULL && q->val == val )//确定头结点
{
q=p->next;
}
if( q == NULL)
q=p->next;
while( q!=NULL )
{
if(q->val == val)//如果出现val
{
q=q->next;
}
else
{
p->next = q;
p=q;
q = q->next;
}
}
p->next = q;
}
};

#### 203. Remove Linked List Elements [easy] (Python)

2016-06-18 16:30:01

2016-04-13 08:31:57

#### 203. Remove Linked List Elements（python）

2016-09-18 21:39:48

#### leetcode 203: Remove Linked List Elements

2015-04-25 06:47:30

#### 【LeetCode】 203. Remove Linked List Elements C语言

2017-04-18 09:11:18

2017-01-29 14:40:09

2017-10-05 11:21:59

#### leetcode 203 Remove Linked List Elements C++

2016-06-11 14:29:46

#### leetcode 203 Remove Linked List Elements

2015-04-29 15:01:55

2015-08-26 07:21:56