Intersection of Linked List Problem Statement
You are provided with two singly linked lists of integers. These lists merge at a node of a third linked list.
Your task is to determine the data of the node where merging begins. If there is no intersection, return -1.
Example:
Input Format:
The input format consists of three lines, each representing a singly linked list.
Each line contains the elements of a singly linked list separated by a space and terminated by -1.
For instance, the first linked list might look like: a1 a2 ... an c1 -1.
The second line could be: b1 b2 ... bm c1 -1.
The third line might be: c2 c3 ... ck -1.
Output Format:
Your output should be a single line that contains the data of the first merged node.
If there is no intersection, output should be -1.
You do not need to print anything explicitly; it is handled for you.
Constraints:
- 0 ≤ N ≤ 105
- 0 ≤ M ≤ 105
- 0 ≤ K ≤ 105
- -109 ≤ data ≤ 109, and data ≠ -1
- Time Limit: 1 second

AnswerBot
4mo
Given two linked lists, find the node where they intersect, if any.
Traverse both lists to find their lengths and the difference in lengths
Move the pointer of the longer list by the difference in lengt...read more
Help your peers!
Add answer anonymously...
Ernst & Young Associate Software Engineer interview questions & answers
An Associate Software Engineer was asked Q. Design an Airline Management System.
An Associate Software Engineer was asked Q. What is an AVL tree?
An Associate Software Engineer was asked Q. Share your college coding experience.
Popular interview questions of Associate Software Engineer
An Associate Software Engineer was asked Q1. What is an AVL tree?
An Associate Software Engineer was asked Q2. Share your college coding experience.
An Associate Software Engineer was asked Q3. What are OOPs Concepts?
>
Ernst & Young Associate Software Engineer Interview Questions
Stay ahead in your career. Get AmbitionBox app


Trusted by over 1.5 Crore job seekers to find their right fit company
80 L+
Reviews
10L+
Interviews
4 Cr+
Salaries
1.5 Cr+
Users
Contribute to help millions
AmbitionBox Awards
Get AmbitionBox app

