Back to DSA

Serialize and Deserialize Binary Tree

hard
Acceptance: 44%
Binary Tree

Construct an algorithm that converts a binary tree into a string representation and another that reconstructs the original tree from that string. The format of the string is your design choice, but the round-trip must be lossless.

Examples

Example 1:
Input:root = [3,1,5,null,null,2,7]
Output:[3,1,5,null,null,2,7]

Hints

00:00
1234567