← 返回 doordash 的题目列表Serialize and Deserialize Binary Tree
类型:online_judge
doordash
Given a binary tree, implement two algorithms to serialize and deserialize the binary tree. Serialization is the process of converting the tree into a string, and deserialization is the reverse, creating the tree from the string representation. You can choose your own method for encoding and decoding as long as the process is consistent.
Test cases:
Serialization: serialize(root)
Deserialization: deserialize(data)
Data scale:
Binary tree with up to 10,000 nodes.
Example
Input
1,2,null,null,3,4,null,null,5,null,null