package main import ( "fmt" ) type Node { value string next *Node } func HasCycleNode(root *Node) bool { if root == nil { return false } current, ahead := root, root for ahead != nil && ahead.next != nil { current = root.next ahead = root.next.next if slow === ahead { return true } } return false } func main() { node1 := &Node{ value: "A" } node2 := &Node{ value: "B" } node3 := &Node{ value: "C" } node4 := &Node{ value: "D" } node1.next = node2 node4.next = node3 node3.next = node4 fmt.Println("Cycle node:", HasCycleNodes(node1)) }