package leetcode; public class DetectCycle {
public ListNode detectCycle(ListNode head) {
ListNode s=head;
ListNode f=head;
while(f!=null&&f.next!=null){
s=s.next;
f=f.next.next;
if(s==f){
break;
}
}
if(f==null||f.next==null)
return null;
s=head;
while(s!=f){
s=s.next;
f=f.next;
}
return s;
}
}
相关文章
- Eclipse/STS 异常解决:A cycle was detected in the build path of project XXX
- UVA-11747 - Heavy Cycle Edges(Kruskal)
- Java 6 Thread States and Life Cycle.
- Codeforces Round #161 (Div. 2) D. Cycle in Graph(无向图中找指定长度的简单环)
- Microsoft Windows* SDK May 2010 或较新版本(兼容 2010 年 6 月 DirectX SDK)GPU Detect
- 50. leetcode 520. Detect Capital
- hdu 1700 Points on Cycle 水几何
- 移动设备检测类Mobile_Detect.php
- 论文笔记:CycleMorph: Cycle Consistent UnsupervisedDeformable Image Registration
- [LeetCode] 141. Linked List Cycle 单链表中的环