Complete the code to find the middle index of the array segment.
int mid = start + ([1] - start) / 2;
The middle index is calculated by adding start to half the distance between end and start.
Complete the code to create a new TreeNode with the middle element.
TreeNode node = new TreeNode([1][mid]);The input array is named nums, so we use nums[mid] to get the middle element.
Fix the error in the recursive call to build the left subtree.
node.left = SortedArrayToBST([1], start, mid - 1);
The recursive call must pass the original array nums to build the subtree.
Fill both blanks to complete the recursive call for the right subtree and return the node.
node.right = SortedArrayToBST([1], mid + 1, [2]); return [3];
The right subtree uses nums, from mid + 1 to end. Then we return the current node.
Fill all three blanks to complete the base case and start the recursive call.
if (start > [1]) return null; return SortedArrayToBST([2], [3], end);
The base case checks if start is greater than end. The recursive call starts from start to end on nums.
