Leetcode 141. Linked List Cycle
floyd circle detection algorithm(龟兔赛跑算法)
class Solution(object): def hasCycle(self, head): """ :type head: ListNode :rtype: bool """ try: slow = head fast = head.next while slow is not fast: slow = slow.next fast = fast.next.next return True except: return False