```
class Solution {
public:
void dfs(TreeNode *&p,int l,int r,vector<int> &num){
if(l>r){p=NULL; return;}
p->val=num[(l+r)/2];
TreeNode *left,*right;
p->left=left;
p->right=right;
dfs(left,l,(l+r)/2-1,num);
dfs(right,(l+r)/2+1,r,num);
}
TreeNode *sortedArrayToBST(vector<int> &num) {
TreeNode *head;
dfs(head,0,num.size()-1,num);
return head;
}
};
```

Runtime Error, why?