package main
import . "nc_tools"

//双指针法
func hasCycle( head *ListNode ) bool {
    // write code here
    fast, slow := head, head
    for fast != nil && fast.Next != nil {
        fast = fast.Next.Next
        slow = slow.Next
        if fast == slow {
            return true
        }
    }
    return false
}