Design an algorithm to serialize a binary tree into a string, and deserialize that string back into the original tree structure.
Input: root = [1,2,3,null,null,4,5]
Output: [1,2,3,null,null,4,5]
Explanation: Serializing then deserializing reproduces the original tree.
Topics: trees
Asked by: Amazon, Meta, Microsoft, Google
Time complexity: O(n). Space complexity: O(n).