Linked List Cycle
来源:互联网 发布:淘宝店主图图片尺寸 编辑:程序博客网 时间:2024/06/06 21:02
Given a linked list, determine if it has a cycle in it.
LintCode上原题
* Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */class Solution {public: bool hasCycle(ListNode *head) { if(!head) return false; ListNode *fast=head,*slow=head; while(fast&&fast->next){ slow=slow->next; fast=fast->next->next; if(slow==fast) return true; } return false; }};
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
- mybatis开发(第二天)
- Android中的线程池
- 使用OkHttp的那些事儿(二)
- 禁忌搜索算法
- struct class
- Linked List Cycle
- PHP迭代模式的Iterator和IteratorAggregate
- 【死磕Java并发】-----Java内存模型之分析volatile
- 加载assets资源和xml解析
- springmvc集成 velocity,实现多视图整合(jsp,velocity)
- 入门练习小总结
- 【设计模式】六个创建型模式
- poj 2392 Space Elevator (多重背包)
- GCC 编译优化指南