[leetcode]Maximum Binary Tree – by c++ – CY-Left
Given an integer array with no duplicates. A maximum tree building on this array is defined as follow:
给出一个整型不重复数组。现用这些数组构建一个最大树,最大树定义如下
- The root is the maximum number in the array.
根是数组中最大数 -
The left subtree is the maximum tree constructed from left part subarray divided by the maximum number.
左子树由该数组中最大值的左半边组成 -
The right subtree is the maximum tree constructed from right part subarray divided by the maximum number.
右子树是由该数组最大值的右半边组成
Construct the maximum tree by the given array and output the root node of this tree.
通过给定的数组构建最大树,并返回头节点。
比如:
给出: [3,2,1,6,0,5]
输出: 如下数组
6 / \ 3 5 \ / 2 0 \ 1
Note:
- 给定数组范围 [1,1000].
Read full article from [leetcode]Maximum Binary Tree – by c++ – CY-Left
No comments:
Post a Comment