Given the head of a linked list and a value, delete all nodes that have the given value and return the head of the modified list.
Input
head: the head node of a singly linked list
value: an integer value to search for and delete
Output
Return the head of the modified linked list with all occurrences of the value removed
Constraints
The list may be empty
The value may or may not exist in the list
Multiple nodes may have the same value
Examples
Example 1
Inputhead = [1, 2, 3, 2, 4], value = 2
Output[1, 3, 4]
ExplanationRemove all nodes with value 2
Example 2
Inputhead = [1, 1, 1], value = 1
Output[]
ExplanationAll nodes have value 1, result is empty list
Example 3
Inputhead = [1, 2, 3], value = 4
Output[1, 2, 3]
ExplanationValue 4 doesn't exist, list unchanged