Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Node ¶
type Node struct {
Parent *Node
}
Node has a pointer to its parent.
func LowestCommonAncestor ¶
LowestCommonAncestor returns the lowest common ancestor. Returns nil if the two nodes don't share a common node. Assumes the graph is a DAG. Any cycles returns nil. Runs in O(N) time and stores 1 path so technically O(N) memory.
Click to show internal directories.
Click to hide internal directories.