Deserialize from preorder and computed inorder, reusing old solution
I serialize the tree's values in preorder. For deserializing, I additionally compute inorder simply by sorting the preorder. And then I just use the buildTree f
I serialize the tree's values in preorder. For deserializing, I additionally compute inorder simply by sorting the preorder. And then I just use the `buildTree` function that I copied&pasted from [my old solution](https://discuss.leetcode.com/topic/16221/simple-o-n-without-map) for the old problem [Construct Binary Tree from Preorder and Inorder Traversal](https://leetcode.com/problems/construct-binary-tree-from-preorder-and-inorder-traversal/).\n```\nclass Codec:\n\n    def serialize(self, root):\n        def preorder(node):\n            if node:\n                vals.append(str(node.val))\n                preorder(node.left)\n                preorder(node.right)\n        vals = []\n        preorder(root)\n        return ' '.join(vals)\n\n    def deserialize(self, data):\n        preorder = map(int, data.split())\n        inorder = sorted(preorder)\n        return self.buildTree(preorder, inorder)\n\n    def buildTree(self, preorder, inorder):\n        def build(stop):\n            if inorder and inorder[-1] != stop:\n                root = TreeNode(preorder.pop())\n                root.left = build(root.val)\n                inorder.pop()\n                root.right = build(stop)\n                return root\n        preorder.reverse()\n        inorder.reverse()\n        return build(None)\n```\n(I had seen @shallpion's [title](https://discuss.leetcode.com/topic/65773/construct-bst-using-preorder-traversal) saying "preorder" before thinking about this problem, so can't be sure I would've had the idea myself, though I think I would've.)
[]