当前位置:网站首页>142. Circular linked list II

142. Circular linked list II

2022-07-05 01:12:00 qq_ forty-eight million two hundred and thirty thousand four hu

Given the head node of a linked list head , Return to the first node of the link where the list begins to enter . If the list has no links , Then return to null.

If there is a node in the linked list , It can be done by continuously tracking next The pointer reaches again , Then there is a ring in the linked list . To represent a ring in a given list , The evaluation system uses an integer pos To indicate where the end of the list is connected to the list ( Index from 0 Start ). If pos yes -1, There are no links in the list . Be careful :pos Not passed as an argument , Just to identify the actual situation of the linked list .

No modification allowed Linked list .

-------------------------------------------------------------------------

Ideas : Speed pointer When they met, the quick pointer had gone n Double ring therefore Let's start again Step-by-step Meeting the slow pointer is the circular entrance

原网站

版权声明
本文为[qq_ forty-eight million two hundred and thirty thousand four hu]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202141045414069.html