I would really appreciate it if some one can tell me why. I am so confused. I tried to declare the return vector every possible place with any name and got AC all the time without returning it.

(I tried for more than 20 times and all got AC. PS, with a return I got AC as expected.)

```
class Solution {
public:
vector<TreeNode*> generateTrees(int end, int begin = 1){
TreeNode * root;
vector<TreeNode*> leftchildren,rightchildren;
vector<TreeNode*> result;
if(begin > end)
{
result.push_back(NULL);
return result;
}
for(int i = begin; i <= end; i++)
{
leftchildren = generateTrees(i - 1, begin);
rightchildren = generateTrees(end, i+1);
for(auto l: leftchildren)
for(auto r:rightchildren)
{
root = new TreeNode(i);
root->left = l;
root->right = r;
result.push_back(root);
}
}
//return result; //where it suppose to be
}
};
```