



The first line contains an integer 'T' which denotes the number of test cases or queries to be run. Then, the T test cases follow.
The first line of each test case contains space-separated integers denoting the values of nodes of the Linked List. The Linked List is terminated with -1. Hence, -1 is never a node value of the Linked List.
The second line of each test case contains a single integer 'K' which denotes the value of the nodes to be removed.
For each test case, print the elements of the resultant Linked List after removing all nodes having the value 'K'.
You do not need to print anything. It has already been taken care of. Just implement the given function.
1 <= T <= 10
1 <= N <= 10^5
0 <= node.data <= 10^9 and node.data != -1
0 <= K <= 10^9
Where 'node.data' denotes the value of a Linked list node, and 'K' denotes the value of the nodes to be removed.
Time limit: 1 sec
Approach: The idea is to use recursion to solve the problem. The working of the recursive function is explained below. The basic idea is pretty simple that if a node has value K, then we will remove this node from the Linked List, and our output will be the node returned by the recursive call for its next node. Otherwise, our output will be the current node itself.
Approach: The idea is to convert the previous approach into an iterative approach. To do so, we will find the first node from the left whose value is not equal to ‘K’. This node will be the head node of our final Linked List. Now we will iterate through the right of this node and will insert all the nodes in the Linked List whose value is not equal to ‘K’.