141. Linked List Cycle(C语言版本)
来源:互联网 发布:linux mint 18 编辑:程序博客网 时间:2024/06/08 13:49
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. * struct ListNode { * int val; * struct ListNode *next; * }; */bool hasCycle(struct ListNode *head) { struct ListNode *fast,*slow; fast = slow = head; while( slow && fast && fast->next ){ fast=fast->next->next; slow=slow->next; if(fast==slow) return true; } return false;}
阅读全文
0 0
- 141. Linked List Cycle(C语言版本)
- 【LeetCode】141. Linked List Cycle C语言
- [C语言][LeetCode][141]Linked List Cycle
- 【C++】【LeetCode】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
- bzoj 4028: [HEOI2015]公约数数列 (分块乱搞+map)
- centos7搭建gitlab(二)之gitlab仓库迁移
- Ajax XHR2详解
- CSS元素分类(按照样式属性)
- Activity中finish() onDestroy() 和System.exit()的区别
- 141. Linked List Cycle(C语言版本)
- 线程池编程
- 给eclipse安装反编译
- mysql加索引
- Python备份数据库并定期删除n天前的备份数据(本地)
- IntelliJ Idea 常用快捷键列表
- 欢迎使用CSDN-markdown编辑器
- Python 学习日知录(五)- 配置文件之二
- 谈一谈UIScrollView的scrollsToTop属性