```
class Solution {
public:
ListNode* removeElements(ListNode* head, int val) {
ListNode *prehead=new ListNode(-1);
prehead->next=head;
ListNode *current=prehead;
ListNode *tmp=prehead->next;
while(tmp)
{
while(tmp->val==val)
tmp=tmp->next;
current->next=tmp;
current=current->next;
tmp=current->next;
}
return prehead->next;
}
};
```

when the testcase is [1] 1,or [1,1] 1,or [1,1,...]1 ,the code status is wrong time error.