Appearance
def hasCycle(self, head: Optional[ListNode]) -> bool: fast = slow = head while fast and fast.next: fast = fast.next.next slow = slow.next if slow == fast: return true return false
时间复杂度:O(n) 空间复杂度:O(1)