diff --git a/linked_lists/intersection.py b/linked_lists/intersection.py index f07e2ae..4c03aa0 100644 --- a/linked_lists/intersection.py +++ b/linked_lists/intersection.py @@ -11,4 +11,19 @@ def intersection_node(headA, headB): """ Will return the node at which the two lists intersect. If the two linked lists have no intersection at all, return None. """ - pass \ No newline at end of file + if not headA or not headB: + return None + + a = headA + b = headB + + while a != b: + if a: + a = a.next + else: + a = headB + if b: + b = b.next + else: + b = headA + return a \ No newline at end of file