Construct Binary Tree from Preorder and Inorder Traversal Solutions in PythonNumber 105Difficulty MediumAcceptance 49.0%Link LeetCodeOther languages C++, GoSolutionsPython solution by haoel/leetcodedef buildTree(self, preorder, inorder): if inorder: i = inorder.index(preorder.pop(0)) root = TreeNode(inorder[i]) root.left = self.buildTree(preorder, inorder[:i]) root.right = self.buildTree(preorder, inorder[i+1:]) return rootdef buildTree(self, preorder, inorder): if inorder: i = inorder.index(preorder.pop(0)) root = TreeNode(inorder[i]) root.left = self.buildTree(preorder, inorder[:i]) root.right = self.buildTree(preorder, inorder[i+1:]) return root