0203 - Remove Linked List Elements
Last updated
Last updated
Given the head of a linked list and an integer val, remove all the nodes of the linked list that has Node.val == val, and return the new head.
Input: head = [1,2] Output: [2,1]
Input: head = [] Output: []
The number of nodes in the list is the range [0, 5000]. -5000 <= Node.val <= 5000
Follow up: A linked list can be reversed either iteratively or recursively. Could you implement both?