297. Serialize and Deserialize Binary Tree
Solutions
Serialize
Print the tree in pre-order traversal. Explicitly noted down null
nodes.
Deserialize
Use queue to deserialize the pre-order traversal.
Since null
node is stored, we know we should stop when null
is encountered.