Design an algorithm to serialize a binary tree to a string and deserialize that string back to the original tree.
With this tree:
1
/ \
2 3
/ \
4 5
A valid serialization might be "1,2,null,null,3,4,null,null,5,null,null" (preorder with nulls).
serialize(root) returns a string encoding the tree.
deserialize(data) returns the original tree.
The format is up to you, as long as both methods work together.
Constraints: Up to nodes. Values from to .