Given two (non-cyclical) linked lists, determine if the two lists intersect and return the intersecting node. Otherwise, return null. Example: Input: intersectVal = 8, listA = [4,1,8,4,5], listB = [5,6,1,8,4,5] Output: Reference to node with value 8 Explanation: Lists intersect at the node with value 8. Pattern focus: Fast and Slow Pointers (two-pointer technique with switching heads).
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 starts at node with value 8.