Remove every node from a singly linked list whose value appears in a given array.
You are given the head of a singly linked list and an array of integers. Delete every node from the linked list whose value is present in the array.
Return the head of the modified linked list.
The relative order of the remaining nodes should stay the same.
head: head of a singly linked listnums: integer array of values to deletenumsnums should not change the resultExample 1
Input
head = [1,2,3,4,5], nums = [2,4]
Output
[1,3,5]
Explanation
Nodes with values 2 and 4 are removed.
Example 2
Input
head = [7,7,7], nums = [7]
Output
[]
Explanation
Every node matches a value to delete, so the list becomes empty.
Premium problem context
Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.