203. 移除链表元素(Easy)
Python示例
class Solution:
def removeElements(self, head: ListNode, val: int) -> ListNode:
dummpyHead = ListNode(None)
dummpyHead.next = head
p = dummpyHead
while p and p.next:
if p.next.val == val:
p.next = p.next.next
else:
p = p.next
return dummpyHead.next