Skip to main content
Construct Binary Tree from Preorder and Inorder Traversal | AlgoCracked
AlgoCracked
ProblemsConstruct Binary Tree from Preorder and Inorder Traversal
Medium62.0% acceptance
Blind75ArrayHash TableDivide And ConquerTree

Construct Binary Tree from Preorder and Inorder Traversal

Given two integer arrays preorder and inorder — the preorder and inorder traversals of the same binary tree — reconstruct the tree and return its root. Input format Input is [preorder, inorder] as plain JSON arrays, e.g. [[3,9,20,15,7],[9,3,15,20,7]] . Return the built TreeNode ; the harness serializes it back to a level-order array. TreeNode is predefined.

Loading workspace…