一、203. 移除链表元素
代码:
class Solution:def removeElements(self, head: Optional[ListNode], val: int) -> Optional[ListNode]:while head and head.val == val:head = head.nextpre, cur = head, headwhile cur:if cur.val == val:pre.next = cur.nextelse:pre = curcur = cur.next return head