Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 14 additions & 6 deletions linked_lists/intersection.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,22 @@



class Node:
def __init__(self, value):
self.val = value
self.next = None
def __init__(self, value, next_node=None):
self.value = value
self.next = next_node


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
if headA is None or headB is None:
return None

# Use current values for the pointers:
pointer_a, pointer_b = headA, headB
# Use a while loop that
while pointer_a != pointer_b:
pointer_a = headB if pointer_a is None else pointer_a.next
pointer_b = headA if pointer_b is None else pointer_b.next

return pointer_a
Empty file added linked_lists/requirements.txt
Empty file.