We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 4901165 commit 34a2bc8Copy full SHA for 34a2bc8
203.js
@@ -0,0 +1,28 @@
1
+/**
2
+ * Definition for singly-linked list.
3
+ * function ListNode(val) {
4
+ * this.val = val;
5
+ * this.next = null;
6
+ * }
7
+ */
8
9
+ * @param {ListNode} head
10
+ * @param {number} val
11
+ * @return {ListNode}
12
13
+var removeElements = function(head, val) {
14
+ while(head !== null){
15
+ if(head.val !== val) break;
16
+ head = head.next;
17
+ }
18
+ if(head === null) return head;
19
+ var temp = head;
20
+ while(temp.next !== null){
21
+ if(temp.next.val === val){
22
+ temp.next = temp.next.next;
23
+ }else{
24
+ temp = temp.next;
25
26
27
+ return head;
28
+};
0 commit comments