LeetCode 141. Linked List Cycle
2015-06-24 20:52
363 查看
/** * 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) return false; ListNode slow = head; while (head != null && head.next != null) { head = head.next.next; slow = slow.next; if (head == slow) return true; } return false; } }
相关文章推荐
- [原创]使用Spring的HibernateDaoSupport实现BaseDaoImpl类
- linux常用命令
- OC11_真正的代理
- 【Web缓存机制系列】6 – 进击的Hybrid App,量身定做缓存机制
- RecyclerView的基本使用
- 3-40
- Eclipse折叠代码 coffee bytes code folding
- LeetCode 171. Excel Sheet Column Number
- android 学习网址
- 1009. 说反话 (20)
- Bootstrap系列 -- 12. 水平表单
- Spring事务管理
- MulticastDelegate
- LeetCode 191. Number of 1 Bits
- JSP页面EL表达式无效的问题
- 外键约束列没建索引导致大量library cache pin/library cache lock
- 开始学习 Backbone
- Sql学习入门------基本语句
- openGL 坐标系的互相转换
- SylixOS动态加载器系列文章(1) ELF文件格式