TreeNode* bst(vector a,int s,int e)

{

if(s>e) return NULL;

```
int mid = (s+e) / 2;
TreeNode* r = new TreeNode(a[mid]);
r->left = bst(a,s,mid-1);
r->right = bst(a,mid+1,e);
return r;
```

}

TreeNode* Solution::sortedArrayToBST(const vector &a) {

return bst(a,0,a.size()-1);

}