Design serialize(root) -> str and deserialize(s) -> root so that any binary tree (with integer values, possibly negative or repeated) round-trips exactly. Use a preorder walk writing values separated by commas and # for missing children.
Unlock this and every premium problem across all tracks — plus hidden-test grading, advanced AI engineering modules and new content every week.
Start 7-day free trial