Given an integer array nums where the elements are sorted in ascending order, convert it to a height-balanced binary search tree.
Example 1
Input: nums = [-10,-3,0,5,9]
Output: [0,-10,5,null,-3,null,9]
Explanation: The middle value 0 becomes the root. The left half [-10,-3] becomes a subtree rooted at -10 with -3 on its right, and the right half [5,9] becomes a subtree rooted at 5 with 9 on its right. Both sides have height 2, so the tree is balanced.
Example 2
Input: nums = [1,3]
Output: [1,null,3]
Explanation: Picking 1 as the root with 3 as its right child gives a valid, balanced BST. [3,1] would also be balanced; this answer picks the left middle.
Example 3
Input: nums = [0]
Output: [0]
Explanation: A single value becomes a one-node tree.
Pick the middle element as the root so the two halves have (nearly) equal size — that guarantees balance. Recurse on the left half for the left subtree and the right half for the right subtree.
Run checks all cases above. Submit evaluates all test cases.