Intersection of two Linked Lists
Description
- Given the heads of two singly linked-lists
headA
andheadB
, return the node at which the two lists intersect. If the two linked lists have no intersection at all, returnnull
.
For example, the following two linked lists begin to intersect at node c1:
Example |
The test cases are generated such that there are no cycles anywhere in the entire linked structure.
Note that the linked lists must retain their original structure after the function returns.
Constraints
Test Cases
-
Input:
Output: -
Input:
Output: