Problem title
Difficulty
Avg time to solve

Contains Duplicate ll
Easy
15 mins
Easy
15 mins
Paths in a Maze
Easy
--
Smallest Window
Moderate
10 mins
Triple Sum
Easy
15 mins
Maximum In Sliding Windows Of Size K
Moderate
20 mins
Easy
10 mins
Build Heap
Moderate
30 mins
String Maker
Hard
50 mins
Minimum and Maximum Cost to buy N Candies
Hard
10 mins
5

# Search in a Linked List

Difficulty: EASY
Contributed By
Avg. time to solve
10 min
Success Rate
90%

Problem Statement

#### Now you have been given an integer value 'K'. Your task is to check whether a node having a value equal to 'K' exists in the given linked list or not.

##### Input Format:
``````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.
``````
##### Output Format:
``````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.
``````
##### Note:
``````You do not need to print anything, and it has already been taken care of. Just implement the given function.
``````
##### Constraints:
``````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.
``````
##### Sample Input 1:
``````2
3 6 2 7 9 -1
2
1 3 8 7 -1
5
``````
##### Sample Output 1:
``````1
0
``````
##### Explanation for Sample Input 1:
``````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.
``````
##### Sample Input 2:
``````1
1 2 3 7 -1
7
``````
##### Sample Output 2:
``````1
``````
##### Explanation for Sample Input 2:
``````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.
``````
Console