Delete All Occurrences of a Given Key in a Linked List
Given the head of a linked list and a key, delete all nodes whose values match the given key.
We'll cover the following...
We'll cover the following...
Statement
We’re given the head of a linked list and a key. Delete all the nodes that contain the given key.
Note: The input linked list will not have cycles in it.
Example
The following example elaborates this problem further:
The linked list, after we delete key 72:
Sample input
[20, 14, 36, 11, 72, 41]
key = 72
Expected output
[20, 14, 36, 11, 41]