Back to problems

Reconstruct Binary Tree from Preorder and Postorder

Algorithm · ByteDance · Hard

Construct Binary Tree from Preorder and Postorder Traversal Medium · Topics · Company Tags · Hints You are given the preorder and postorder sequences of an unknown binary tree containing distinct integer values. Rebuild the original tree and return its root. The input arrays represent the same tree traversal and are guaranteed to be valid. Because preorder-plus-postorder information does not uniquely determine a tree when a node has only one child, you may return any valid…

Checking your access…