LeetCode 106, Medium . Topics: Array , Hash Table , Divide and Conquer , Tree , Binary Tree . View on LeetCode .
Generate this problem as a practice environment: tested reference solution, 15 parametrized pytest cases , and a playground notebook:
Problem
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 .
Examples
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
Solution
Reference implementation from solution.py on GitHub , full suite in test_solution.py :
Complexity
NeetCode All .Last modified on September 7, 2026