README ¶ 面试题 04.05.合法二叉搜索树 1. 题目描述 实现一个函数,检查一棵二叉树是否为二叉搜索树。 示例 1: ``` 输入: 2 / \ 1 3输出: true **示例 2:** ``` 输入: 5 / \ 1 4 / \ 3 6输出: false解释: 输入为: [5,1,4,null,null,3,6]。 根节点的值为 5 ,但是其右子节点值为 4 。 标签 树 深度优先搜索 二叉搜索树 二叉树 2. 解题 Expand ▾ Collapse ▴ Documentation ¶ Index ¶ type TreeNode func BuildTree(preorder []int, inorder []int) *TreeNode func (root *TreeNode) InOrder(Visit func(val int)) func (root *TreeNode) PostOrder(Visit func(val int)) func (root *TreeNode) PreOrder(Visit func(val int)) 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)) Source Files ¶ View all Source files Tree.gogoden0405.go Click to show internal directories. Click to hide internal directories.