Complete the code to find the middle index of the array slice.
let mid = (start + [1]) / 2;
The middle index is calculated by averaging the start and end indices.
Complete the code to create a new TreeNode with the middle element as value.
let node = TreeNode::new([1][mid]);The input array is named nums, so we access nums[mid] to get the middle element.
Fix the error in the recursive call to build the left subtree.
node.left = build_bst(nums, start, [1] - 1);
The left subtree uses the range from start to mid - 1.
Fill both blanks to build the right subtree correctly.
node.right = build_bst(nums, [1], [2]);
The right subtree covers the range from mid + 1 to end.
Fill all three blanks to complete the base case and recursive call in the helper function.
if [1] > [2] { return None; } let mid = (start + end) / 2; let mut node = TreeNode::new(nums[mid]); node.left = build_bst(nums, start, mid - 1); node.right = build_bst(nums, mid + 1, [3]); Some(Box::new(node))
The base case checks if start is greater than end. The right subtree ends at end.
