From 59cb4b9c8fca6588097481fc14a8585d051e4441 Mon Sep 17 00:00:00 2001 From: syblades <86990570+syblades@users.noreply.github.com> Date: Tue, 1 Nov 2022 14:56:49 -0700 Subject: [PATCH] All tests passing --- linked_lists/intersection.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/linked_lists/intersection.py b/linked_lists/intersection.py index f07e2ae..b0992db 100644 --- a/linked_lists/intersection.py +++ b/linked_lists/intersection.py @@ -11,4 +11,17 @@ 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 + head_one = headA + head_two = headB + while head_one != head_two: + if head_one: + head_one = head_one.next + else: + head_one = headB + if head_two: + head_two = head_two.next + else: + head_two = headA + return head_one + +