← 返回 bytedance 的题目列表Serialize and Deserialize Binary Tree
类型:online_judge
Implement an algorithm to serialize a binary tree into a string, and then deserialize the string back into the binary tree. Requirements:
You are free to design your own serialization method, but you must be able to deserialize the string back to the original tree.
The serialization and deserialization should be consistent such that a tree serialized and then deserialized should be identical to the original tree.
Example:
Input: root = [1,2,3,null,null,4,5]
Output: [1,2,3,null,null,4,5]
Data Constraints:
The number of nodes in the tree is in the range [0, 10^4].
-1000 <= Node.val <= 1000
Example
Input
root = [1,2,3,null,null,4,5]