day112

package
v0.0.0-...-36687a4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 28, 2020 License: MIT Imports: 0 Imported by: 0

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

func LowestCommonAncestor(n1, n2 *Node) *Node

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL