class Solution: # @param head, a ListNode # @return a boolean def hasCycle(self, head): if None == head or None == head.next: return False pfast = head pslow = head while pfast and pfast.next: pfast = pfast.next.next pslow = pslow.next if pfast == pslow: return True return False这个题是很经典的题,要我说什么,我也说不出什么,只是觉得这种算法(想法)和nb,仅此而已。
相关文章
- 01-07leetcode:Odd Even Linked List
- 01-07[leetcode] Reverse Linked List 分类: leetcode 算法 2015-07-09 18:44 2人阅读 评论(0) 收藏
- 01-07【LeetCode】109. Convert Sorted List to Binary Search Tree 解题报告(Python)
- 01-07[LeetCode203]Remove Linked List Elements
- 01-07LeetCode解题报告—— Reverse Linked List II & Restore IP Addresses & Unique Binary Search Trees II
- 01-07[LeetCode] 141. Linked List Cycle 单链表判圆算法
- 01-07【Leetcode】141. 环形链表(Linked List Cycle)
- 01-07LeetCode 141. Linked List Cycle--百度面试编程题--C++,Python解法
- 01-07leetcode 206. Reverse Linked List
- 01-07[LeetCode] 426. Convert Binary Search Tree to Sorted Doubly Linked List