106. Construct Binary Tree from Inorder and Postorder Traversal
Medium
Previous105. Construct Binary Tree from Preorder and Inorder TraversalNext108. Convert Sorted Array to Binary Search Tree
Last updated
Medium
Last updated
Given two integer arrays inorder
and postorder
where inorder
is the inorder traversal of a binary tree and postorder
is the postorder traversal of the same tree, construct and return the binary tree.
Example 1:
Example 2:
Constraints:
1 <= inorder.length <= 3000
postorder.length == inorder.length
-3000 <= inorder[i], postorder[i] <= 3000
inorder
and postorder
consist of unique values.
Each value of postorder
also appears in inorder
.
inorder
is guaranteed to be the inorder traversal of the tree.
postorder
is guaranteed to be the postorder traversal of the tree.
Runtime: 0 ms, faster than 100%
Memory Usage: 4.1 MB, less than 63.44%