Documentation
¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Is ¶
Is reports whether the singly linked list has cycles. It uses fast and slow pointers algorithm instead of a set of visited nodes.
Example ¶
package main
import (
"fmt"
"github.com/skhal/lab/iq/18/cycle"
)
func main() {
head := &cycle.Node{
Val: 1,
Next: &cycle.Node{
Val: 2,
Next: &cycle.Node{
Val: 3,
},
},
}
head.Next.Next = head
fmt.Println(cycle.Is(head))
}
Output: true
Types ¶
Click to show internal directories.
Click to hide internal directories.