203. Remove Linked List Elements
Practice Remove Linked List Elements for free on NudgeCode: Easy, Linked List pattern. Write it in Python or JavaScript, run the tests in your browser, and ask for a hint when you are stuck.
Delete every node whose value equals val from a linked list and return the head of what remains. The head itself may need to be deleted, and the result may be empty.
Example
head = [1,2,6,3,4,5,6], val = 6 -> [1,2,3,4,5]
head = [7,7,7,7], val = 7 -> []
Constraints
- 0 <= length of the list <= 10^4
- 1 <= Node.val <= 50
- 0 <= val <= 50