/**
* Definition for singly-linked list.
* type ListNode struct {
* Val int
* Next *ListNode
* }
*/
func contain(node_list []*ListNode, node *ListNode) bool {
for _, n := range node_list {
if n == node {
return true
}
}
return false
}
func hasCycle(head *ListNode) bool {
var seen_nodes []*ListNode
for head!=nil {
if contain(seen_nodes, head) {
return true
}
seen_nodes = append(seen_nodes, head)
head = head.Next
}
return false
}