def hasCycle(head):
    """
    Use two pointers(one slow, one fast) to traverse the list.
    Two pointers are bound to meet if there is a cycle;
    otherwise, fast pointer will reach the end eventually.
    """
    slow = head
    fast = head
    while fast and fast.next:  # note the condition
        slow = slow.next
        fast = fast.next.next
        if slow == fast:
            return True
    return False