Singly linked list intersection problem (single linked list has a ring problem)

Check if two singly linked lists intersect:

https://blog.csdn.net/tianyunzqs/article/details/48413165

Best way: O(max[mn])

If the two singly linked lists are both acyclic singly linked lists, connect the first position of one of the singly linked lists, and then judge whether the other singly linked list has a cycle. If there is a cycle, it means that the two singly linked lists intersect.

If one has a cycle and one does not, the two singly linked lists do not intersect.

If both singly linked lists have loops, check whether the positions of the loop connection points are the same.

 

Check if a singly linked list has a cycle

Determine the position of the connection point of a singly linked list with a ring

Determining the ring length of a singly linked watch with a ring

Determine the total length of a singly linked list with a ring

https://www.cnblogs.com/xudong-bupt/p/3667729.html

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325044983&siteId=291194637