Serialize and Deserialize BST | Python
\ndef serialize(self, root: TreeNode) -> str:\n        vals = []\n\n        def preOrder(node):\n            if node:\n                vals.append(node.val)\n  
```\ndef serialize(self, root: TreeNode) -> str:\n        vals = []\n\n        def preOrder(node):\n            if node:\n                vals.append(node.val)\n                preOrder(node.left)\n                preOrder(node.right)\n\n        preOrder(root)\n\n        return \' \'.join(map(str, vals))\n        \n        \n        \n\n    def deserialize(self, data: str) -> TreeNode:\n        vals = collections.deque(int(val) for val in data.split())\n\n        def build(minVal, maxVal):\n            if vals and minVal < vals[0] < maxVal:\n                val = vals.popleft()\n                node = TreeNode(val)\n                node.left = build(minVal, val)\n                node.right = build(val,maxVal)\n                return node\n\n        return build(float(\'-inf\'), float(\'inf\'))\n\n```
[]