From bd1dc3a9e74c9b4f7775d2c7f331ecd8d5b9c717 Mon Sep 17 00:00:00 2001 From: Olive Lavine Date: Thu, 13 Oct 2022 17:44:49 -0500 Subject: [PATCH] solution --- linked_lists/intersection.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/linked_lists/intersection.py b/linked_lists/intersection.py index f07e2ae..009b0d4 100644 --- a/linked_lists/intersection.py +++ b/linked_lists/intersection.py @@ -11,4 +11,14 @@ 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 + currentB = headB + while currentA: + while currentB: + if currentA == currentB: + return currentA + currentB = currentB.next + currentA = currentA.next + currentB = headB + return None + \ No newline at end of file