本题最关键是要理解 虚拟头结点的使用技巧这个对链表题目很重要。近期对链表的一系列学习我感觉难度越来越大东西也越来越深奥。后续的学习需要花费更多的时间。#include stdlib.h struct ListNode* removeElements(struct ListNode* head, int val) { struct ListNode *dummy (struct ListNode*)malloc(sizeof(struct ListNode)); dummy-next head; struct ListNode *curr dummy; while (curr-next ! NULL) { if (curr-next-val val) { struct ListNode *temp curr-next; curr-next curr-next-next; free(temp); } else { curr curr-next; } } struct ListNode *newHead dummy-next; free(dummy); return newHead; }