leetcode_c++:链表:Linked List Cycle(141)
来源:互联网 发布:测音高的软件 编辑:程序博客网 时间:2024/06/05 00:20
Given a linked list, determine if it has a cycle in it.
O(n)
class Solution {public: bool hasCycle(ListNode *head) { if(head==NULL ||head->next==NULL) return false; ListNode* fast=head; ListNode* slow=head; do{ slow=slow->next; fast=fast->next->next; }while(fast!=NULL && fast->next!=NULL && fast!=slow); return fast==slow? true:false; }};
0 0
- leetcode_c++:链表:Linked List Cycle(141)
- leetcode_c++:链表:Linked List Cycle II(142)
- leetcode_c++:链表:Linked List Cycle II(142)
- 141Linked List Cycle
- #141 Linked List Cycle
- 141 Linked List Cycle
- [141]Linked List Cycle
- 141Linked List Cycle
- 141-Linked List Cycle
- 141 Linked List Cycle
- 141 linked list cycle
- 141-Linked List Cycle
- Leetcode#141(链表)-Linked List Cycle
- 链表-leetcode 141 Linked List Cycle
- leetcode_c++:链表:Reverse Linked List II (092)
- leetcode_c++:链表:Remove Linked List Elements(203)
- leetcode_c++:链表:Palindrome Linked List(234)
- leetcode_c++:链表:Odd Even Linked List(328)
- git之:创建与合并分支
- 【OpenCV】轮廓处理
- 欢迎使用CSDN-markdown编辑器
- Android Studio调试
- 项目 笔记
- leetcode_c++:链表:Linked List Cycle(141)
- mysql数据库语句
- 怎样自动调节NiceLabel中文本框大小?
- 无法访问localhost和127.0.0.1的内容
- android.content.res.Resources$NotFoundException: String resource ID #0xffffffff
- [Java]Java程序的编译步骤
- 如何使360浏览器中的Google可用
- hdoj2796
- MySQL Quick guide