feat: removeElements

This commit is contained in:
xuwu 2021-04-14 07:54:05 +08:00
parent d41dfad254
commit 70516c9818

View File

@ -0,0 +1,15 @@
var removeElements = function(head, val) {
const dummy = new ListNode()
let node = dummy
while (head) {
const tmp = head.next
if (head.val !== val) {
node.next = head
node = head
}
head = tmp
}
node.next = null
return dummy.next
};