I encountered various errors while implementing the logic for https://leetcode.com/problems/construct-binary-tree-from-inorder-and-postorder-traversal/ and https://leetcode.com/problems/construct-binary-tree-from-preorder-and-inorder-traversal/
General solutions for both that passed all test cases:
https://leetcode.com/submissions/detail/526513144/
https://leetcode.com/submissions/detail/526684560/
I am going to list down the errors and will appreciate if someone can clarify them:
root->left=func(.......);
root->right=func(......);After this got submitted successfully, I exchanged the order in which I was calling, i.e.,
root->right=func(.......);
root->left=func(......);This gives me heap buffer overflow.
Can someone explain why this is happening?