Correct binary tree preorder/inorder to postorder implementation passes all visible tests but fails eLab Logical Test 4
enter image description hereI am solving a binary tree traversal problem on a university eLab programming platform. The problem is: Given the preorder and inorder traversals of a binary tree with n distinct nodes, output its postorder traversal. The constraints are: 1 ≤ n ≤ 10^5 The nodes are numbered from 1 to n. Example Input: 5 5 3 2 1 4 3 5 1 2 4 Expected output: 3 1 4 2 5 Another test case: 6 6 5 3 2 1 4 6 3 5 1 2 4 Expected output: 3 1 4 2 5 6 My implementation uses the standard reconstruction idea, but instead of recursion I use an iterative stack, because n can be as large as 100000. H
0 upvotes
View original discussion ↗
Comments
Sign in or sign up to comment and upvote.
No comments yet.