[leetcode] Linked List Cycle II
来源:互联网 发布:获取ip及端口号 编辑:程序博客网 时间:2024/04/27 17:32
public ListNode detectCycle(ListNode head)
{
ListNode slow, fast;
slow = fast = head;
while(slow != null && slow.next != null && fast != null && fast.next != null)
{
slow = slow.next;
fast = fast.next.next;
if(slow == fast)
{
ListNode p = head;
while(p != slow)
{
p = p.next;
slow = slow.next;
}
return p;
}
}
return null;
}
{
ListNode slow, fast;
slow = fast = head;
while(slow != null && slow.next != null && fast != null && fast.next != null)
{
slow = slow.next;
fast = fast.next.next;
if(slow == fast)
{
ListNode p = head;
while(p != slow)
{
p = p.next;
slow = slow.next;
}
return p;
}
}
return null;
}
0 0
- 【LeetCode】 Linked List Cycle II
- Leetcode: Linked List Cycle II
- <Leetcode>Linked List Cycle II
- [LeetCode] Linked List Cycle II
- Leetcode: Linked List Cycle II
- LeetCode:Linked List Cycle II
- Leetcode Linked List Cycle II
- [LeetCode]Linked List Cycle II
- leetcode Linked List Cycle II
- LeetCode | Linked List Cycle II
- Leetcode: Linked List Cycle II
- [LeetCode] - Linked List Cycle II
- Leetcode: Linked List Cycle II
- LeetCode - Linked List Cycle II
- leetcode Linked List Cycle II
- Linked List Cycle II -- LeetCode
- LeetCode Linked List Cycle II
- [LeetCode] Linked List Cycle II
- Swoole源码学习记录(九)——Factory模块(上)
- iOS中的多线程------+NSThread与NSOperation
- 怎么去提供网站信用度
- 哈夫曼树
- iOS 8 Size Classes初探
- [leetcode] Linked List Cycle II
- Spring SpringMvc 406 Not Acceptable
- new start,new target...
- java主要集合类的数据结构
- SQL Server 2008 R2 删除过期备份
- 状态机模式
- 上篇--ARM时钟初始化--了解时钟体系--国嵌第三季-专题7
- 在Ubuntu上搭建keystone开发测试环境
- ubuntu 14.04 登录 界面 root