TreeNode* BST(vector<int>&nums,int left, int right){
if(left>right){
return nullptr;
}
int mid=left+(right-left)/2;
TreeNode* node=new TreeNode(nums[mid]);
node->left=BST(nums,left,mid-1);
node->right=BST(nums,mid+1,right);
return node;
}
TreeNode* sortedArrayToBST(vector<int>& nums) {
return BST(nums,0,nums.size()-1);
}