代码面试集锦 2 - Google
程序员文章站
2023-09-01 08:07:41
Given the root to a binary tree, implement serialize(root), which serializes the tree into a string, and deserialize(s), which deserializes the string ......
given the root to a binary tree, implement serialize(root), which serializes the tree into a string, and deserialize(s), which deserializes the string back into the tree.
for example, given the following node class
class node: def __init__(self, val, left=none, right=none): self.val = val self.left = left self.right = right
the following test should pass:
node = node('root', node('left', node('left.left')), node('right')) assert deserialize(serialize(node)).left.left.val == 'left.left'
上一篇: 一阵大风刮过女生寝室后
下一篇: 如何减肚子上的赘肉 跪式俯卧撑提臀运动