57. Remove Linked List Elements

Given a singly linked list head and an integer val. Remove all nodes with value val and return the head of the list.
Example 1
Input: head = [7,7,7,7], val = 7
Output: []
Explanation: All nodes are removed and the list becomes empty.
Example 2
Input: head = [1,2,6,3,4,5,6], val = 6
Output: [1,2,3,4,5]
Explanation: All nodes with value 6 are removed; the others keep their order.
easylinked list
JavaScript
Loading...
Line 1, Char 1