Skip to content

Commit fd74804

Browse files
authored
Create README.md
1 parent 1f82602 commit fd74804

File tree

1 file changed

+60
-0
lines changed

1 file changed

+60
-0
lines changed
+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
Given two singly linked lists of size N and M, write a program to get the point where two linked lists intersect each other.
2+
3+
4+
5+
Example 1:
6+
7+
Input:
8+
```
9+
LinkList1 = 3->6->9->common
10+
LinkList2 = 10->common
11+
common = 15->30->NULL
12+
Output: 15
13+
Explanation:
14+
15+
![linked](https://user-images.githubusercontent.com/63565510/126059709-0aaf5d20-a74d-41aa-817f-53af16944bdf.jpg)
16+
17+
Y ShapedLinked List
18+
Example 2:
19+
20+
Input:
21+
Linked List 1 = 4->1->common
22+
Linked List 2 = 5->6->1->common
23+
common = 8->4->5->NULL
24+
Output: 8
25+
Explanation:
26+
27+
4 5
28+
| |
29+
1 6
30+
\ /
31+
8 ----- 1
32+
|
33+
4
34+
|
35+
5
36+
|
37+
NULL
38+
```
39+
Your Task:
40+
41+
You don't need to read input or print anything. The task is to complete the function intersetPoint() which takes the pointer to the head of linklist1(head1) and linklist2(head2) as input parameters and returns data value of a node where two linked lists intersect. If linked list do not merge at any point, then it should return -1.
42+
Challenge : Try to solve the problem without using any extra space.
43+
44+
45+
46+
Expected Time Complexity: O(N+M)
47+
48+
Expected Auxiliary Space: O(1)
49+
50+
51+
52+
53+
Constraints:
54+
55+
1 ≤ N + M ≤ 2*105
56+
57+
-1000 ≤ value ≤ 1000
58+
59+
60+

0 commit comments

Comments
 (0)