2dafd8f09ef34f49429538b6e532f72a
(难度Easy) Problem 108. Convert Sorted Array to Binary Search Tree(有序序列构建平衡二叉树)

Convert Sorted Array to Binary Search Tree

Difficulty

Easy

Description

Given an array where elements are sorted in ascending order, convert it to a
height balanced BST.

For this problem, a height-balanced binary tree is defined as a binary tree in
which the depth of the two subtrees of _every_ node never differ by more than
1.

Example:

Given the sorted array: [-10,-3,0,5,9],

One possible answer is: [0,-3,9,-10,null,5], which represents the following height balanced BST:

      0
     / \
   -3   9
   /   /
 -10  5

题意

给定一个升序的序列,将它转化为平衡二叉树。

平衡二叉树顾名思义,是指二叉树的任意两个子树的深度差不超过1.

题解

top Created with Sketch.