Loading...
Design an algorithm to serialize a binary tree to a string and deserialize it back.
Input: level-order array (comma-separated, 'null' for missing). Output: serialized then deserialized back to level-order.
1,2,3,null,null,4,5
1 2 3 null null 4 5
1,2,3,null,null,4,5 is first split into an array of node values, representing a level-order traversal of the binary tree.null values indicate missing nodes:
1 2 3 null null 4 5.