Login

All Problems

Problem title

Difficulty

Avg time to solve

Vertex Cover Problem

Moderate

25 mins

Ninja and his dessert.

Easy

10 mins

Distinct Characters

Moderate

15 mins

Group Anagrams Together

Moderate

--

Intersection of Linked Lists

Easy

20 mins

Power of Three

Easy

15 mins

Save The World

Hard

45 mins

Number of ones in the smallest repunit

Moderate

30 mins

Ninja And Number Game

Hard

50 mins

Knight Tour

Moderate

25 mins

Problem

Submissions

0

Avg. time to solve

20 min

Success Rate

70%

Problem Statement

```
L1 = 1->2->3->4->7
L2 = 2->4->6->7
ANSWER:- The answer should be 2->4->7 because 2,4, and 7 are present in both the linked lists.
```

```
The first line contains a single integer ‘T’ representing the number of test cases. Then each test case follows.
The first line of every test case contains the nodes of the first linked list. The line ends with -1 to indicate that the linked list is over.
The next line of every test case contains the head of the second linked list. The line ends with -1 to indicate that the linked list is over.
```

```
For each test case, return the head of the intersecting linked list. If the intersecting linked list is empty, return NULL (denoted by -1).
The output of each test case should be printed in a separate line.
```

```
You are not required to print anything, it has already been taken care of. Just implement the function.
```

```
1 <= T <= 5
1 <= Length of the the two linked lists <= 10^5
Time Limit = 1 sec
```

```
2
1 3 5 -1
1 2 4 -1
2 3 -1
2 3 4 -1
```

```
1 -1
2 3 -1
```

```
In the first test case, the intersecting linked list is 1, so the node containing 1 is returned.
In the second test case, the intersecting linked list is 2->3, so the node containing 2 is returned.
```

```
1
2 3 4 -1
1 5 6 -1
```

```
-1
```

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 Language

Change Theme

Solution submission not allowed

Save Code

Reset Code