Binary search tree with minimal height means: we want the root to be the middle of the array.
TreeNode* builder (vector<int>& nums, int start, int end){
if( start > end) return nullptr;
int idx = start+(end-start)/2;
TreeNode* root = new TreeNode(nums[idx]);
root->left = builder(nums, start, idx-1);
root->right = builder(nums, idx+1, end);
return root;
}
TreeNode *sortedArrayToBST(vector<int> &A) {
// write your code here
return builder(A, 0, A.size()-1);
}