From a0a4f183fa34468ede0c1966675a0987ba3a6a5d Mon Sep 17 00:00:00 2001 From: Alexa Coffman Date: Wed, 21 Dec 2022 18:17:29 -0800 Subject: [PATCH] Implements intersection_node function --- linked_lists/intersection.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/linked_lists/intersection.py b/linked_lists/intersection.py index f07e2ae..ee287ea 100644 --- a/linked_lists/intersection.py +++ b/linked_lists/intersection.py @@ -11,4 +11,16 @@ 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 + currentA = headA + + while currentA: + currentB = headB + while currentB: + if currentA == currentB: + return currentA + currentB = currentB.next + currentA = currentA.next + + return None + +