All Problems

Problem title

Difficulty

Avg time to solve

Contains Duplicate ll

Easy

15 mins

Program to validate IP address

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

Search in a Linked List

Easy

10 mins

Build Heap

Moderate

30 mins

String Maker

Hard

50 mins

Minimum and Maximum Cost to buy N Candies

Hard

10 mins

Problem

Submissions

5

Avg. time to solve

10 min

Success Rate

90%

Problem Statement

```
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.
```

Java (SE 1.8)

Console

Sample Test Case

Custom Test Case

Download Test Cases

Test Case 1

Test Case 2

Test Case 3

Saving Code...

Full Screen Mode

Change Theme

Solution submission not allowed

Save Code

Reset Code