```
public TreeNode sortedArrayToBST(int[] nums) {
return arrayToBSTHelper(nums, 0, nums.length-1);
}
private TreeNode arrayToBSTHelper(int[] nums, int start, int end) {
if (start > end)
return null;
int mid = (start + end) / 2;
TreeNode root = new TreeNode(nums[mid]);
root.left = arrayToBSTHelper(nums, start, mid - 1);
root.right = arrayToBSTHelper(nums, mid + 1, end);
return root;
}
```