class Solution {

public:

TreeNode* sortedArrayToBST(vector<int>& nums) {

return creatBST (nums,0,nums.size()-1);

}

```
TreeNode* creatBST(vector<int>& nums,int m,int n)
{
if(n<m)
return NULL;
TreeNode* newNode=new TreeNode(nums[(m+n)/2]);
newNode->left=creatBST(nums,m,(m+n)/2-1);
newNode->right=creatBST(nums,(m+n)/2+1,n);
return newNode;
}
```

};