problem0889

package
v0.0.0-...-db5e768 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2019 License: MIT Imports: 1 Imported by: 0

README

889. Construct Binary Tree from Preorder and Postorder Traversal

题目

Return any binary tree that matches the given preorder and postorder traversals.

Values in the traversalspre and postare distinctpositive integers.

Example 1:

Input: pre = [1,2,4,5,3,6,7], post = [4,5,2,6,7,3,1]
Output: [1,2,3,4,5,6,7]

Note:

  1. 1 <= pre.length == post.length <= 30
  2. pre[] and post[]are both permutations of 1, 2, ..., pre.length.
  3. It is guaranteed an answer exists. If there exists multiple answers, you can return any of them.

解题思路

见程序注释

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type TreeNode

type TreeNode = kit.TreeNode

TreeNode is definited for a binary tree node.

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

Jump to

Keyboard shortcuts

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