Intersection of Two Linked Lists
Solution ApproachWas this helpful?
Easy•linked-list•Expected: O(N) time, O(1) space
linked-list
Problem
Given the heads of two singly linked lists, return the node at which they intersect, or null.
Example 1:
Input: listA = [4, 1, 8, 4, 5], listB = [5, 6, 1, 8, 4, 5]
(Intersection at node with value 8)
Output: Node with value 8
Example 2:
Input: listA = [2, 6, 4], listB = [1, 5]
(No intersection)
Output: null
Reference solution unlocks after your first submission
Loading...
