题目:

题解:
class Solution {
public:
ListNode* removeElements(ListNode* head, int val) {
struct ListNode* dummyHead = new ListNode(0, head);
struct ListNode* temp = dummyHead;
while (temp->next != NULL) {
if (temp->next->val == val) {
temp->next = temp->next->next;
} else {
temp = temp->next;
}
}
return dummyHead->next;
}
};


















![[图解]企业应用架构模式2024新译本讲解18-活动记录2](https://img-blog.csdnimg.cn/direct/7ba1eb77768d4f85ad7b2c48f0a5b437.png)