添加203.移除链表元素JavaScript版本

This commit is contained in:
qingyi.liu
2021-05-21 13:26:53 +08:00
parent cdb78d1667
commit 05bd25d17c

View File

@ -201,6 +201,28 @@ Python
Go
javaScript:
```js
/**
* @param {ListNode} head
* @param {number} val
* @return {ListNode}
*/
var removeElements = function(head, val) {
const ret = new ListNode(0, head);
let cur = ret;
while(cur.next) {
if(cur.next.val === val) {
cur.next = cur.next.next;
continue;
}
cur = cur.next;
}
return ret.next;
};
```