```
class Solution {
public:
TreeNode *sortedArrayToBST(vector<int> &num) {
if(num.size() == 0) return NULL;
TreeNode *root = NULL;
next(0,num.size()-1,root,num);
return root;
}
void next(int left,int right,TreeNode *tmp,vector<int> &vect)
{
tmp = new TreeNode(vect[(left+right)/2]);
if(left == right)
return;
next(left,(left+right)/2,tmp->left,vect);
next((left+right)/2+1,right,tmp->right,vect);
}
};
```