Determine whether the two linked lists intersect, and if so, return the intersecting node

Here I only provide ideas, if you want code, chat with me privately~~~

1. Determine whether to intersect

Find the last node of the two linked lists to see if they are the same, if they are the same, they intersect, and vice versa.

2. Find the difference between the lengths of the two linked lists

Why do you need to find the difference between two linked lists?

In order to judge which is longer, so that the long linked list will go to the difference first, so that it is convenient to find the intersection

3. Find the intersection

After the long walk, it is convenient to walk the long and short together to find the intersection node

Guess you like

Origin blog.csdn.net/llt2997632602/article/details/130092430