Keep getting runtime error even for [-1] [-1]. But runs fine locally. Anyone throw some light?

```
class Solution {
public:
TreeNode *recursiveBuilder(int inorder[], int postorder[], int n) {
if (n==0) return NULL;
int rootval = postorder[n-1];
TreeNode temp(rootval);
TreeNode *root = &temp;
int i = 0;
while (inorder[i]!=rootval) ++i;
root->left = recursiveBuilder(inorder, postorder, i);
root->right = recursiveBuilder(inorder+i+1, postorder+i, n-i-1);
return root;
}
TreeNode *buildTree(vector<int> &inorder, vector<int> &postorder) {
return recursiveBuilder(&inorder[0], &postorder[0], inorder.size());
}
};
```