1. 题目
2. 题解
# 141
class TreeNode:
def __init__(self, x):
self.val = x
self.next = None
class Solution:
def hasCycle(self, head: TreeNode) -> bool:
if head is None:
return False
slow = head
fast = head
while slow is not None and fast is not None:
slow = slow.next
fast = fast.next.next
if slow == fast:
return True
return False