Confused about this inorder, post order input


  • 0
    T

    [2,3,1], [3,2,1] is the input. Maybe I'm just getting it all wrong, but if [3,2,1] is the post order traversal, that means 1 is the root. Since 1 is also the last element of inorder traversal, that means there is no right subtree. This makes 3 the left most node, which means it must be visited first in the inorder traversal. So, I'm not quite sure how [2,3,1], [3,2,1] can be a valid input?


  • 1
    S

    The tree looks like below:

         1
       / 
     2
      \
       3

  • 0
    T

    Thank you, yeah I missed one, but once I know what the tree looks like debugging is easy.


Log in to reply
 

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