Q108. Convert Sorted Array to Binary Search Tree
PreviousQ107. Binary Tree Level Order Traversal IINextQ109. Convert Sorted List to Binary Search Tree
Last updated
Was this helpful?
Last updated
Was this helpful?
直达:
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 ofeverynode never differ by more than 1.
Example:
在有序数组中,去中间元素作为根节点,左侧序列迭代的构建新的子树作为根节点的左子树,右侧部分作为右子树。递归进行直到序列为空。