Ruby recursive solution 6 lines
What we know is that the root node in a postorder traversal is the very last node, so the last value is the root val. With that we know where to split the inord
What we know is that the root node in a postorder traversal is the very last node, so the last value is the root val. With that we know where to split the inorder traversal because in the inorder array, everything left of the root val is the left side of the tree, and everything right of the root val is the right side of the tree. We also know that in the postorder traversal there is some middle point of the traversal that splits the left and right of the tree because we know that the traversal jumps to the right side of the root node only after the entire left side is completed. Now, since we know the exact number of nodes on the left side from our logic about the inorder traversal array, we can take exactly that many values from the postorder traversal array for the left side, and then take the remaining values minus the last value for the right side.\n\n```\ndef build_tree(inorder, postorder)   \n    \n    return nil if inorder.none?\n    \n    node = TreeNode.new(postorder.last)\n    i = inorder.index(postorder.last)\n    node.left = build_tree(inorder[0...i], postorder[0...i])\n    node.right = build_tree(inorder[i+1..-1], postorder[i...-1])\n    \n    node\n    \nend\n```
[]