Find Merge Point of Two Lists:

"""
 Find the node at which both lists merge and return the data of that node.
 head could be None as well for empty list
 Node is defined as

 class Node(object):

   def __init__(self, data=None, next_node=None):
       self.data = data
       self.next = next_node


"""

def FindMergeNode(headA, headB):
    l=[]
    while headA!=None:
        l.append(headA.data)
        headA = headA.next
    while headB!=None:
        if headB.data in l:
            return headB.data
        else:
            headB = headB.next

results matching ""

    No results matching ""