File tree 2 files changed +28
-0
lines changed
2 files changed +28
-0
lines changed Original file line number Diff line number Diff line change 46
46
141|[ Linked List Cycle] ( ./0141-linked-list-cycle.js ) |Easy|
47
47
151|[ Reverse Words in a String] ( ./0151-reverse-words-in-a-string.js ) |Medium|
48
48
152|[ Maximum Product Subarray] ( ./0152-maximum-product-subarray.js ) |Medium|
49
+ 203|[ Remove Linked List Elements] ( ./0203-remove-linked-list-elements.js ) |Easy|
49
50
217|[ Contains Duplicate] ( ./0217-contains-duplicate.js ) |Easy|
50
51
219|[ Contains Duplicate II] ( ./0219-contains-duplicate-ii.js ) |Easy|
51
52
226|[ Invert Binary Tree] ( ./0226-invert-binary-tree.js ) |Easy|
Original file line number Diff line number Diff line change
1
+ /**
2
+ * 203. Remove Linked List Elements
3
+ * https://leetcode.com/problems/remove-linked-list-elements/
4
+ * Difficulty: Easy
5
+ *
6
+ * Given the head of a linked list and an integer val, remove all the
7
+ * nodes of the linked list that has Node.val == val, and return the
8
+ * new head.
9
+ */
10
+
11
+ /**
12
+ * Definition for singly-linked list.
13
+ * function ListNode(val, next) {
14
+ * this.val = (val===undefined ? 0 : val)
15
+ * this.next = (next===undefined ? null : next)
16
+ * }
17
+ */
18
+ /**
19
+ * @param {ListNode } head
20
+ * @param {number } val
21
+ * @return {ListNode }
22
+ */
23
+ var removeElements = function ( head , val ) {
24
+ if ( ! head ) return null ;
25
+ head . next = removeElements ( head . next , val ) ;
26
+ return head . val === val ? head . next : head ;
27
+ } ;
You can’t perform that action at this time.
0 commit comments