141.Linked List Cycle (判断一个单链表是否有环)
来源:互联网 发布:冰箱品牌知乎 编辑:程序博客网 时间:2024/05/18 20:49
public class Solution {
public boolean hasCycle(ListNode head) {
ListNode slow = head, fast = head;
while (fast != null && fast.next != null) {
slow = slow.next;
fast = fast.next.next;
if (slow == fast)
return true;
}
return false;
}
}
public boolean hasCycle(ListNode head) {
ListNode slow = head, fast = head;
while (fast != null && fast.next != null) {
slow = slow.next;
fast = fast.next.next;
if (slow == fast)
return true;
}
return false;
}
}
0 0
- 141.Linked List Cycle (判断一个单链表是否有环)
- 141. Linked List Cycle | 判断单链表是否有环
- 141. Linked List Cycle (判断单链表中是否有环)
- 141. Linked List Cycle 判断单链表中是否有环
- 链表-Linked List Cycle II(判断一个链表是否有环)
- 判断链表是否有环 Linked List Cycle, Linked List Cycle II
- 判断链表是否有环 Linked List Cycle
- Linked List Cycle --判断链表是否有环
- leetcode--Linked List Cycle--判断链表是否有环
- Linked List Cycle 判断链表是否有环
- leetcode_141. Linked List Cycle 判断链表中是否有环
- Linked List Cycle:判断链表是否有环
- Linked List Cycle-- 判断一个单向链表中是否有环存在
- Leetcode ☞ 141. Linked List Cycle 【快慢指针 判断是否有环】
- 【Leetcode】141. Linked List Cycle-判断链表是否有环
- LeetCode | Linked List Cycle(判断链表是否有环)
- [LeetCode-141] Linked List Cycle(判断链表是否有环)
- leetcode解题之141# Linked List Cycle Java版 (判断链表是否有环)
- C# BackgroundWorker的使用
- Android线程调度机制
- Debug Current Instruction Pointer
- PARSEC测试集的应用领域和working set的大小
- 程序加入对话框代码LogCat报错空指针
- 141.Linked List Cycle (判断一个单链表是否有环)
- nyoj35表达式求值
- 利用反射输出类的结构:方法、构造器签名和全部域名
- iOS中MapKit
- 什么类型客户适合做展示型网站
- oracle公用分页存储过程
- android开发中出现的错误集(不断更新)
- 欢迎使用CSDN-markdown编辑器
- eclipse的快捷键--收藏