###### [leetcode 203] Remove Linked List Elements

Question:

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

1、链表是否为空；

2、要删除的元素是否与表头元素相等。

<span style="font-size:14px;">/**
* struct ListNode {
*     int val;
*     ListNode *next;
*     ListNode(int x) : val(x), next(NULL) {}
* };
*/
class Solution {
public:
ListNode* removeElements(ListNode* head, int val) {
}
ListNode* p;
ListNode* q;
while(p != NULL && p->next != NULL){
if(p->next->val == val)
p->next = p->next->next;
else
p = p->next;
}

}
};</span>

#### 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

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

2016-06-11 14:29:46

2015-08-26 07:21:56

#### LeetCode 203. Remove Linked List Elements 解题报告

2016-02-20 15:31:06

#### leetcode 203 Remove Linked List Elements

2015-04-29 15:01:55

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

2016-06-18 16:30:01

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

2016-09-18 21:39:48

2016-04-13 08:31:57

2017-01-29 14:40:09

## 不良信息举报

[leetcode 203] Remove Linked List Elements