mirror of
https://github.com/KieSun/all-of-frontend.git
synced 2024-11-17 04:18:15 +08:00
feat: removeElements
This commit is contained in:
parent
d41dfad254
commit
70516c9818
@ -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
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user