# class ListNode:
# def __init__(self, x):
# self.val = x
# self.next = None
#
#
# @param head ListNode类
# @return bool布尔型
#
class Solution:
def hasCycle(self , head ):
# write code here
if not head:
return False
slow, fast = head, head
while 1:
if fast and fast.next: #没有环的情况下,保证fast最后停在none
slow = slow.next
fast = fast.next.next
if fast == slow:
return True
else:
return False
08-30
1万+
04-01
1325
12-25
728
02-26
243