Recursive solution Python with O(N) time
\n# Definition for a binary tree node.\n# class TreeNode:\n#     def __init__(self, val=0, left=None, right=None):\n#         self.val = val\n#         self.lef
```\n# Definition for a binary tree node.\n# class TreeNode:\n#     def __init__(self, val=0, left=None, right=None):\n#         self.val = val\n#         self.left = left\n#         self.right = right\n\'\'\'\n             0 1 2  3  4\ninorder =   [9,3,15,20,7]\n             l         r\n           l r   l     r\n\t\t\t\npostorder = [9,15,7,20,3]\n             l         r\n           l r l     r\n\'\'\'\n\nclass Solution:\n    def buildTree(self, inorder: List[int], postorder: List[int]) -> Optional[TreeNode]:\n        def rec(in_l, in_r, post_l, post_r):\n            if in_l > in_r:\n                return None\n            if in_l == in_r:\n                return TreeNode(inorder[in_l])\n            \n            pivot_val = postorder[post_r]\n            left_node_nums = inorder_dict[pivot_val] - in_l\n            \n            pivot_node = TreeNode(pivot_val)\n            pivot_node.left = rec(in_l, inorder_dict[pivot_val] - 1, post_l, post_l + left_node_nums - 1)\n            pivot_node.right = rec(inorder_dict[pivot_val] + 1, in_r, post_l + left_node_nums, post_r - 1)\n            \n            return pivot_node\n            \n        inorder_dict = {val : idx for idx, val in enumerate(inorder)}\n        \n        N = len(postorder)\n        return rec(0, N - 1, 0, N - 1)\n```
['Recursion', 'Python', 'Python3']