Skip to content

Commit e32bad1

Browse files
authored
Update 203-remove-linked-list-elements.js
1 parent 7981f56 commit e32bad1

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

203-remove-linked-list-elements.js

+20
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,23 @@ const removeElements = function(head, val) {
2727
}
2828
return dummy.next
2929
};
30+
31+
// another
32+
33+
/**
34+
* Definition for singly-linked list.
35+
* function ListNode(val) {
36+
* this.val = val;
37+
* this.next = null;
38+
* }
39+
*/
40+
/**
41+
* @param {ListNode} head
42+
* @param {number} val
43+
* @return {ListNode}
44+
*/
45+
const removeElements = function(head, val) {
46+
if (head === null) return null;
47+
head.next = removeElements(head.next, val);
48+
return head.val === val ? head.next : head;
49+
};

0 commit comments

Comments
 (0)