As far as I know, construction of "subvectors" could be expensive ( O(n) operation). So I tried to avoid creating new vectors for performance. Here's my solution.

```
class Solution {
TreeNode *dfs(vector<int> &num, int start, int end) {
int idx = start + (end-start)/2;
TreeNode *node = new TreeNode(num[idx]);
//Base case
if(end == start)
return node;
//recurse if valid
if(start <= idx-1)
node->left = dfs(num, start, idx-1);
if(idx+1 <= end)
node->right = dfs(num, idx+1, end);
return node;
}
public:
TreeNode *sortedArrayToBST(vector<int> &num) {
if(num.empty()) return nullptr; //check empty case
return dfs(num, 0, num.size()-1);
}
};
```