208. Serialize and Deserialize Binary Tree

HardTree

Design an algorithm to serialize a binary tree into a string and deserialize that string back into the original tree structure. Serialization converts the tree into a format that can be stored or transmitted, and deserialization reconstructs the tree from that format. There is no restriction on how your serialization and deserialization algorithms should work, as long as a tree can be serialized and then deserialized back to the same structure.

Examples

Input: [1,2,3,4,5,6,7]

Output: [1,2,3,4,5,6,7]

Explanation: Public test case for Serialize and Deserialize Binary Tree

Constraints

  • The number of nodes in the tree is in the range [0, 10^4]
Loading...

Run checks this input. Submit evaluates all test cases.