goden0405

package
v0.0.0-...-b071cee Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2023 License: GPL-3.0 Imports: 0 Imported by: 0

README

面试题 04.05.合法二叉搜索树

1. 题目描述

实现一个函数,检查一棵二叉树是否为二叉搜索树。 示例 1: ``` 输入: 2 / &#92 1 3输出: true

 **示例 2:** ```
输入:    5   / &#92  1   4     / &#92    3   6输出: false解释: 输入为: [5,1,4,null,null,3,6]。     根节点的值为 5 ,但是其右子节点值为 4 。

标签 深度优先搜索 二叉搜索树 二叉树

2. 解题

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type TreeNode

type TreeNode struct {
	Val   int
	Left  *TreeNode
	Right *TreeNode
}

func BuildTree

func BuildTree(preorder []int, inorder []int) *TreeNode

func (*TreeNode) InOrder

func (root *TreeNode) InOrder(Visit func(val int))

func (*TreeNode) PostOrder

func (root *TreeNode) PostOrder(Visit func(val int))

func (*TreeNode) PreOrder

func (root *TreeNode) PreOrder(Visit func(val int))

Jump to

Keyboard shortcuts

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