## 題解 ## 快慢指針 跑操場倒追原理 ```python= # Definition for singly-linked list. # class ListNode: # def __init__(self, x): # self.val = x # self.next = None class Solution: def hasCycle(self, head: Optional[ListNode]) -> bool: slow,fast = head,head while slow and fast: fast = fast.next slow = slow.next if fast: fast = fast.next if fast == slow: return True return False ```