141. Linked List Cycle (判断单链表中是否有环)
来源:互联网 发布:红米note只有2g网络 编辑:程序博客网 时间:2024/05/20 06:29
Given a linked list, determine if it has a cycle in it.
Follow up:
Can you solve it without using extra space?
/** * Definition for singly-linked list. * class ListNode { * int val; * ListNode next; * ListNode(int x) { * val = x; * next = null; * } * } */public class Solution { public boolean hasCycle(ListNode head) { if (head == null || head.next == null)return false;ListNode quick = head.next.next, slow = head.next;while (quick != null) {if (quick == slow)return true;if (quick.next == null)return false;else {slow = slow.next;quick = quick.next.next;}}return false; }}
0 0
- 141. Linked List Cycle (判断单链表中是否有环)
- 141. Linked List Cycle 判断单链表中是否有环
- 141. Linked List Cycle | 判断单链表是否有环
- 141.Linked List Cycle (判断一个单链表是否有环)
- 判断链表是否有环 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:判断链表是否有环
- Leetcode ☞ 141. Linked List Cycle 【快慢指针 判断是否有环】
- 【Leetcode】141. Linked List Cycle-判断链表是否有环
- LeetCode | Linked List Cycle(判断链表是否有环)
- [LeetCode-141] Linked List Cycle(判断链表是否有环)
- 链表-Linked List Cycle II(判断一个链表是否有环)
- leetcode解题之141# Linked List Cycle Java版 (判断链表是否有环)
- Linked List Cycle 判断链表是否有环,如果有环,找到环的入口
- 信号通信2.0
- JDBC连接数据库
- 《计算机程序的构造和解释》1.1.4随笔
- linux进程间通信——消息队列
- CentOS7报: Restarting network (via systemctl): Job for network.service failed because the control pr
- 141. Linked List Cycle (判断单链表中是否有环)
- Javascript网页打印大全
- CA核心动画总结
- 1011. World Cup Betting (20)
- 【工具篇】——利用EditPlus进行Json数据格式化
- Python中用MetaClass实现委托、不可变集合
- visual studio 2015 配置 Winpcap
- 第二十天学习笔记
- JavaScript预编译原理分析