Remove every node whose value equals val and return the new head.
The tests show a list as a Python list of its values: [1, 2, 3] stands for 1 -> 2 -> 3.
Example 1
Input:
remove_elements(head, 6) # head = 1 -> 2 -> 6 -> 3 -> 4 -> 5 -> 6
Output:
[1, 2, 3, 4, 5]
Example 2
Input:
remove_elements(head, 7) # head = 7 -> 7 -> 7
Output:
[]
0 <= number of nodes <= 1000000 <= val, node value <= 1000No results yet
Run your code to check it against the examples, or submit to run every test.