← Back to companies
[ OK ] Loaded —
[ INFO ]
$ cd
$ ls -lt
01
02
03
04
05
$ ls -lt
01
02
03
04
05
user@intervues:~/$
Problem Statement
Given the heads of two singly linked lists, headA and headB, return the node at which the two lists intersect. If the two linked lists have no intersection at all, return null. The intersection is defined by reference (node identity), not by value, and the lists may have different lengths before intersecting. You must not modify the linked lists and the lists contain no cycles.[1][7]
Input/Output Examples
Example 1:
intersectVal = 8, listA = [4,1,8,4,5], listB = [5,6,1,8,4,5], skipA = 2, skipB = 3intersected node with value 8 (the common node containing value 8)[7][1]Example 2:
intersectVal = 2, listA = [1,9,1,2,4], listB = [3,2,4], skipA = 3, skipB = 1intersected node with value 2[1][7]Example 3:
intersectVal = 0, listA = [2,6,4], listB = [1,5], skipA = 3, skipB = 2null[7][1]Constraints
listA is in the range [0, 10^4].listB is in the range [0, 10^4].1 <= Node.val <= 10^5 for each node.