From c89012733a0694424d04be729627a50eaf0be199 Mon Sep 17 00:00:00 2001 From: cathos Date: Thu, 6 Oct 2022 17:12:52 -0700 Subject: [PATCH] passed all tests --- linked_lists/intersection.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/linked_lists/intersection.py b/linked_lists/intersection.py index f07e2ae..f0cc339 100644 --- a/linked_lists/intersection.py +++ b/linked_lists/intersection.py @@ -11,4 +11,18 @@ 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 + try: + if headB.next: + headB_first = headB + while headA.next: + while headB.next: + if headA == headB: + return headA + else: + headB = headB.next + else: + headA = headA.next + headB = headB_first + except: + return None + \ No newline at end of file