首页 > 其他 > 详细

Floyd's cycle-finding algorithm

时间:2020-11-25 22:34:44      阅读:58      评论:0      收藏:0      [点我收藏+]

Floyd‘s cycle-finding algorithm

引用维基百科的定义:Floyd‘s cycle-finding algorithm is a pointer algorithm that uses only two pointers, which move through the sequence at different speeds. It is also called the "tortoise and the hare algorithm".

此算法主要应用于链表中,主要是判断链表是否有环以及环的起始位置。

这两个内容刚好对应于 LeetCode 的两道题,此随笔就以这两道题来讲解一下这个巧妙的算法。下面给出这两道题在 LeetCode 中的链接:

判断链表是否有环

链表有环,判断链表环的起始位置

总结

Floyd's cycle-finding algorithm

原文:https://www.cnblogs.com/AuKing/p/14037900.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!