141. Linked List Cycle#2(Done)
来源:互联网 发布:最优化理论 编辑:程序博客网 时间:2024/06/14 06:03
Solution
/** * 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 slow = head; ListNode fast = head.next; while (fast.next != null && fast.next.next != null) { if (slow == fast) { return true; } slow = slow.next; fast = fast.next.next; } return false; }}
Problem#1
* 最好用不可变对象当做HashMap的Key
* 跑圈方法,写总结
0 0
- 141. Linked List Cycle#2(Done)
- 141.Linked List Cycle
- 141. Linked List Cycle
- 141. Linked List Cycle
- 141. Linked List Cycle
- 141. Linked List Cycle
- 141. Linked List Cycle
- 141. Linked List Cycle
- 141. Linked List Cycle
- 141. Linked List Cycle
- 141. Linked List Cycle
- 141. Linked List Cycle
- 141. Linked List Cycle
- 141.Linked List Cycle
- 141. Linked List Cycle
- 141. Linked List Cycle
- 141. Linked List Cycle
- 141. Linked List Cycle
- C++ 模拟Map
- 常见OJ评判结果对照表,作为ACMer你懂得!
- Git之忽略文件篇
- Android服务Binder实现小记
- Node.js入门到精通(6)异步IO
- 141. Linked List Cycle#2(Done)
- Ubuntu(Linux系统)虚拟机工具vmtools详细说明
- PHP实现Excel导入
- final关键字详解
- ps -ef |grep cusip_full_is | grep -v grep | wc -l | awk '{ print $1; }' 这句话是什么意思呢?
- 内核定时器struct timer_list
- Test-济南铁路局科研所
- 高性能javascript技巧
- iOS判断运营商类型