Dsa
Linked List
Medium
Find Intersection of Two Linked Lists
Given two linked lists, determine if they intersect and, if so, return the intersecting node's value. The input will include two linked lists represented as space-separated integers followed by -1 for termination and one line with the starting index of the second linked list in the first (or -1 if they do not intersect). Print the intersecting node's value if they do intersect, otherwise print 'NO INTERSECTION'.
Input Format:
- The first line contains the first linked list.
- The second line contains the second linked list.
- The third line contains the index for the start of the second linked list (-1 if no intersection).
Output Format:
- Print the value of the intersecting node or 'NO INTERSECTION'.
Example:
Input:
4 3 2 1 -1
5 6 -1
2
Output:
1
Key concepts
linked_listintersection
Practise this out loud — free
Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.
🎙 Practise this question now