Problem:
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:
-Summary-
Solve by recursive function call
1. First, find a root first by finding the midpoint of the given integer array.
2. Any numbers on the left should be less than the midpoint number.
Any numbers on the right should be larger than the midpoint number.
3. We keep recursively add the node by find mid and add left and right sub-tree.
모든 문제에 대한 저작권은 LeetCode 회사에 있습니다. [Copyright © 2020 LeetCode]
'LeetCode > Top Interview Q. - Easy' 카테고리의 다른 글
LeetCode. First Bad Version [Sorting and Searching] (0) | 2020.06.08 |
---|---|
LeetCode. Merge Sorted Array [Sorting and Searching] (0) | 2020.06.08 |
LeetCode. Binary Tree Level Order Traversal [Trees] (0) | 2020.06.07 |
LeetCode. Symmetric Tree [Trees] (0) | 2020.06.07 |
LeetCode. Validate Binary Search Tree [Trees] (0) | 2020.06.06 |
댓글