Simple Python solution using recursion!!! 100% working.
Python dictionary can be used in place of index to get linear time complexity.\n\n\n# Code\n\n# Definition for a binary tree node.\n# class TreeNode:\n#     def
**Python dictionary can be used in place of index to get linear time complexity.**\n\n\n# Code\n```\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\nclass Solution:\n    def buildTree(self, inorder: List[int], postorder: List[int]) -> Optional[TreeNode]:\n        if not inorder or not postorder:\n            return None\n        root=TreeNode(postorder.pop())\n        mid=inorder.index(root.val)\n        root.left=self.buildTree(inorder[:mid],postorder[:mid])\n        root.right=self.buildTree(inorder[mid+1:],postorder[mid:])\n        return root\n\n\n\n\n\n```
['Python3']