MLE,and got no idea why ...

• ``````    class Solution {
public:
typedef vector<int>::iterator It;
TreeNode *buildTree2(vector<int> inorder,vector<int> postorder,It inbg,It ined,It pobg,It poed){
if (ined - inbg==0) return NULL;
It pos = find(inbg,ined,*(poed-1));
int size = pos - inbg;
TreeNode *ans = new TreeNode(*(poed-1));
if (ined - inbg==1) return ans;
ans->left = buildTree2(inorder,postorder,inbg,pos,pobg,pobg+size);
ans->right = buildTree2(inorder,postorder,pos+1,ined,pobg+size,poed-1);
return ans;
}
TreeNode *buildTree(vector<int> &inorder, vector<int> &postorder) {
return buildTree2(inorder,postorder,inorder.begin(),inorder.end(),postorder.begin(),postorder.end());
}
};``````

• you may try this：

origin:
TreeNode *buildTree2(vector<int> inorder,vector<int> postorder,It inbg,It ined,It pobg,It poed)

modified:
TreeNode *buildTree2(vector<int>& inorder,vector<int>& postorder,It inbg,It ined,It pobg,It poed)

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.