← All problems
Construct Tree from Preorder and Inorder
Rebuild a binary tree from its preorder and inorder traversals.
Complexity
Time O(n), Space O(n)
Common pitfalls
- Slicing arrays each call (O(n^2))
- Linear search for root in inorder
Your solution
Log in to save your code and track progress.