203 Remove Linked List Elements
Given the
head
of a linked list and an integerval
, remove all the nodes of the linked list that hasNode.val == val
, and return the newhead
.
示例1:
输入:head = [1,2,6,3,4,5,6], val = 6
输出:[1,2,3,4,5]
示例2:
输入:head = [], val = 1
输出:[]
示例3:
输入:head = [7,7,7,7], val = 7
输出:[]