Python Fast DFS with explanation
\n\n\nclass Solution(object):\n    def buildTree(self, inorder, postorder):\n        inorder_map = {val:i for i, val in enumerate(inorder)}\n        \n        d
![image](https://assets.leetcode.com/users/images/ff5d17d7-fe53-485e-a9bb-e386b3e3c7f0_1660911649.0673482.png)\n\n```\nclass Solution(object):\n    def buildTree(self, inorder, postorder):\n        inorder_map = {val:i for i, val in enumerate(inorder)}\n        \n        def dfs(start, end):\n            if start > end: return None\n            root = TreeNode(postorder.pop())\n            root_index = inorder_map[root.val]\n            root.right = dfs(root_index+1, end)  # have to put right before left because postorder.pop will return the right node first\n            root.left = dfs(start, root_index-1)\n            return root\n        \n        return dfs(0, len(inorder)-1)\n```\n![image](https://assets.leetcode.com/users/images/b8e8a9e2-a243-494f-8848-4c82a7c454c9_1660911627.902091.png)\n
['Python']