day93

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

View Source
const MaxInt = int(^uint(0) >> 1)

MaxInt is the largest int.

View Source
const MinInt = -MaxInt - 1

MinInt is the smallest int.

Variables

This section is empty.

Functions

func SizeOfLargestBST

func SizeOfLargestBST(tree *BinaryTree) int

SizeOfLargestBST will return the number of nodes in the largest BST in the binary tree. Runs in O(N) time with no extra space.

Types

type BinaryTree

type BinaryTree struct {
	Value       int
	Left, Right *BinaryTree
}

BinaryTree is a binary tree: left & right children.

func FindLargestBST

func FindLargestBST(tree *BinaryTree) *BinaryTree

FindLargestBST will return a pointer to the root of the largest BST in the binary tree. Runs in O(N) time with no extra space.

type TreeInfo

type TreeInfo struct {
	IsBST  bool
	Min    int
	Max    int
	Size   int
	Ans    int
	AnsPtr *BinaryTree
}

TreeInfo contains information from a given subtree.

Jump to

Keyboard shortcuts

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