package main
import . "nc_tools"
/*
 * type ListNode struct{
 *   Val int
 *   Next *ListNode
 * }
 */

/**
 * 
 * @param head ListNode类 
 * @return bool布尔型
*/
func hasCycle( head *ListNode ) bool {
    fast,slow := head,head
    for fast != nil && slow != nil {
        slow = slow.Next
        if fast.Next == nil {
            return false
        }
        fast = fast.Next.Next
        if slow == fast && slow != nil {
            return true
        }
    }
    return false
}