Problem
Given preorder and inorder traversal arrays of a binary tree, construct and return the binary tree.
References
Difficulty
🟡 Medium
Companies
Amazon, Microsoft, Google
Notes
Language: Java
Preorder first element is always root. Find root in inorder to split left/right subtrees. Use a HashMap for O(1) inorder lookups.
Problem
Given preorder and inorder traversal arrays of a binary tree, construct and return the binary tree.
References
Difficulty
🟡 Medium
Companies
Amazon, Microsoft, Google
Notes
Language: Java
Preorder first element is always root. Find root in inorder to split left/right subtrees. Use a HashMap for O(1) inorder lookups.