From ed2725430a597d31322be65f22beb3f4fc4b45df Mon Sep 17 00:00:00 2001 From: Tyrah Date: Thu, 12 Jan 2023 12:48:37 -0800 Subject: [PATCH] solved intersection of linked lists --- linked_lists/intersection.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/linked_lists/intersection.py b/linked_lists/intersection.py index f07e2ae..6f65ea8 100644 --- a/linked_lists/intersection.py +++ b/linked_lists/intersection.py @@ -11,4 +11,12 @@ 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 + while headB: + temp = headA + while temp: + if temp == headB: + return headB + temp = temp.next + headB = headB.next + + return None \ No newline at end of file