Given a linked list, determine if it has a cycle in it.
slow = fast = head
? ? ? ? while fast and fast.next:
? ? ? ? ? ? fast = fast.next.next
? ? ? ? ? ? slow = slow.next
? ? ? ? ? ? if slow == fast:
? ? ? ? ? ? ? ? return True
? ? ? ? return False
1 一定要考慮特殊情況,比如這道題,如果input是[1]是沒有環(huán)的