Serialize and Deserialize Binary Tree
Design an algorithm to serialize a binary tree to a string and deserialize it back to the original tree structure.
On this platform the tree is supplied as a packed level-order listing of its node values. Children are assigned in breadth-first order and the input carries no null placeholders, so an absent child simply does not appear. The result is the trimmed level-order listing produced by serializing the tree that was rebuilt from the input listing, which means a correct solution performs a genuine serialize and deserialize round trip and returns the original listing.
Examples
Input: [[1,2,3,4,5,6,7]]
Output: [[1,2,3,4,5,6,7]]
Input: [[1]]
Output: [[1]]
Hints
Treat the packed level-order listing as the source of truth for this schema.
Rebuild a tree from the listing, then serialize it back by traversal order.
Return the trimmed level-order listing produced by the round trip.
Related Problems
Serialize and Deserialize Binary Tree
Design an algorithm to serialize a binary tree to a string and deserialize it back to the original tree structure.