97. Convert Sorted Array to Binary Search Tree
EasyBST
Given an integer array nums where the elements are sorted in ascending order, convert it to a height-balanced binary search tree.
Examples
Input: [-10,-3,0,5,9]
Output: [0,-10,5,null,-3,null,9]
Explanation: Middle element 0 becomes the root; each half recursively forms a balanced subtree.
Constraints
- 1 <= nums.length <= 10^4
- -10^4 <= nums[i] <= 10^4
- nums is sorted in a strictly increasing order.
Loading...
Run checks all cases above. Submit evaluates all test cases.