Given the heads of two singly linked-lists that may intersect, return the node at which the intersection begins. If the two lists have no intersection, return null. Example: Input: A = [4,1,8,4,5], B = [5,6,1,8,4,5] Output: 8 Explanation: The intersection starts at node with value 8. Pattern focus: Fast and Slow Pointers (two-pointer technique with switching).
headA = ListNode, headB = ListNode
return ListNode
Example 1:
Input:
headA = [4,1,8,4,5] headB = [5,6,1,8,4,5]
Output:
null
Explanation:
Intersection at node with value 8.
Example 2:
Input:
headA = [0,9,1,2,4] headB = [3,2,4]
Output:
null
Explanation:
Intersection at node with value 2.