7.5 Overlapping List (Python) - may have cycles

#1

Another intuitive way to proceed, after we have ascertained that the lists overlap and have the same cycle.
if root1 != root2: we can return root1 or root2, since it means that these lists meet inside the cycle

if root1 == root2: the lists either meet at the start of the cycle or before the cycle begins. In this case, we can consider root1 to be a tail node. Then use method given in 7.4 )where we advance the longer list etc), to find the first node where the two lists meet.

Does this make sense?

0 Likes

#2

I think you can try your algorithm in our test data for this. I am not very sure what exactly you mean in fact.

0 Likes