245. Serialize and Deserialize N-ary Tree
HardTree
Serialization is the process of converting a data structure or object into a sequence of bits so that it can be stored or transmitted. Design an algorithm to serialize and deserialize an N-ary tree. An N-ary tree is a rooted tree in which each node has no more than N children. There is no restriction on how your serialization/deserialization algorithm should work. You just need to ensure that an N-ary tree can be serialized to a string and this string can be deserialized to the original tree structure.
Examples
Input: [1,null,3,2,4,null,5,6]
Output: [1,null,3,2,4,null,5,6]
Explanation: Serialize and deserialize should return the same tree.
Constraints
- The number of nodes in the tree is in the range [0, 10^4].
- 0 <= Node.val <= 10^4
- The height of the n-ary tree is <= 1000.
Loading...
Run checks this input. Submit evaluates all test cases.