Problem of the day
The first line of the input contains an integer 'T' representing the number of test cases or queries to be processed. Then the 'T' test case follows.
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 third line of each test case contains a single integer 'K' which is desired to be checked in the Linked List.
For more clarity, please refer to the sample inputs.
For each test case, print 1 if the desired value 'K' exists in the Linked List; otherwise, print 0.
Print the answer for each test case in a new line.
You do not need to print anything, and it has already been taken care of. Just implement the given function.
1 <= T <= 10
1 <= L <= 10^5
1 <= data <= 10^9 and data != -1
1 <= K <= 10^9
Where 'T' represents the number of test cases, 'L' represents the total number of nodes in the Linked List, "data" represents the value at each node, and 'K' is the given integer.
Time Limit: 1 sec.
2
3 6 2 7 9 -1
2
1 3 8 7 -1
5
1
0
For the first test case, the given Linked List is
As value 2 exists in the given linked list. So we will return 1 in this case.
And for the second test case, the given Linked List is
As the value 5 is not present in the Linked list. So our answer is 0 in this case.
1
1 2 3 7 -1
7
1
For the first test case, the given Linked List is
As the value 7 exists in the Linked List, so our answer is 1 in this case.