Design an algorithm to serialize a binary tree to a string and deserialize that string back to the original tree structure.
Serialization is the process of converting a data structure into a sequence of bits so it can be stored in a file, memory buffer, or transmitted across a network and reconstructed later in the same or another environment.
You do not need to follow any particular format; the only requirement is that deserialize(serialize(root)) produces a tree that is structurally identical to root with the same node values.
1
/ \
2 3
/ \
4 5
Input: root = [1,2,3,null,null,4,5] Output: [1,2,3,null,null,4,5] Explanation: The tree is serialized to some string and then deserialized back. The round-trip must produce the exact same tree.
Input: root = [] Output: [] Explanation: An empty tree serializes and deserializes back to an empty tree.
[0, 10^4].-1000 <= Node.val <= 1000root = [1,2,3,null,null,4,5]