Problem
Given an integer list nums sorted in strictly increasing order, build a height-balanced binary search tree from it and return the root. Height-balanced means that at every node, the heights of the two subtrees differ by at most 1.
Several trees can be correct. Any height-balanced BST whose in-order walk gives back nums is accepted.
Example 1
- Input
- nums = [-10, -3, 0, 5, 9]
- Output
- [0, -3, 9, -10, null, 5]
- Why
- or [0, -10, 5, null, -3, null, 9], ...
Example 2
- Input
- nums = [1, 3]
- Output
- [3, 1]
- Why
- or [1, null, 3]
Constraints
1 <= nums.length <= 10^4-10^4 <= nums[i] <= 10^4nums is sorted in strictly increasing order.