# class ListNode:
# def __init__(self, x):
# self.val = x
# self.next = None
#
#
# @param head ListNode类
# @return bool布尔型
#快慢指针法:
class Solution:
def hasCycle(self , head ):
if not head:
return False
slow = head
fast = head.next
flag = False
while fast and fast.next:
if slow == fast:
return True
slow = slow.next
fast = fast.next.next
return False
# write code here
03-01
2518
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
12-02
301
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
04-07
458
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
07-12