From 4bb9babd260c6a9f7e0f400bae63bf5b93cbc3fe Mon Sep 17 00:00:00 2001 From: Chinazo Onwukaike Date: Mon, 24 Oct 2022 18:15:04 -0500 Subject: [PATCH] writes and tests code --- 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..89e52c8 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 + + if not headA or not headB: + return None + + while headA: + while headB: + if headA == headB: + return headA + headB == headB.next + headA = headA.next + return None \ No newline at end of file