Linked List Cycle
来源:互联网 发布:飞龙签名设计软件 编辑:程序博客网 时间:2024/05/04 06:06
//快慢指针
public class Solution {
public boolean hasCycle(ListNode head) {
if(head==null)return false;
ListNode slow=head;
ListNode fast=head;
do{
if(fast==null||fast.next==null)return false;
fast=fast.next.next;
slow=slow.next;
} while(fast!=slow);
return true;
}
}
public class Solution {
public boolean hasCycle(ListNode head) {
if(head==null)return false;
ListNode slow=head;
ListNode fast=head;
do{
if(fast==null||fast.next==null)return false;
fast=fast.next.next;
slow=slow.next;
} while(fast!=slow);
return true;
}
}
0 0
- leetcode Linked List Cycle & Linked List Cycle ||
- Linked List Cycle II Linked List Cycle
- 【LeetCode】Linked List Cycle
- Leetcode: Linked List Cycle
- Leetcode Linked List Cycle
- Linked List Cycle
- Linked List Cycle II
- Linked List Cycle
- Linked List Cycle
- Linked List Cycle II
- Leetcode: Linked List Cycle
- LeetCode:Linked List Cycle
- Linked List Cycle II
- Linked List Cycle
- Linked List Cycle II
- [LeetCode]Linked List Cycle
- Linked List Cycle
- LeetCode | Linked List Cycle
- JVM 垃圾回收笔记
- MAC和PHY的区别
- 使用StarUML画类图
- 必须认真学习的算法书
- M - 非常可乐HDU1495 BFS
- Linked List Cycle
- 刘宝庆老师<快速打造中层高效执行力>助理:林静文 电话:18818552408
- HDOJ 1215七夕节
- Linux 下 make 命令 及 make 笔记
- devstack
- 编写一个函数,将一个数字字符串转换成这个字符串对应的数字(包括正浮点数、负浮点数);函数原型:double my_atof(char *str)
- Android 编程下 Touch 事件的分发和消费机制
- JDBC封装
- memset, memcpy, strcpy