Deviopath › Go

Serialize a Tree

Hard · Data Structures

Serialize a binary tree given as nested maps (Val, optional Left/Right) into a preorder string with # for nil, values joined by commas. {"Val":1,"Left":{"Val":2}} becomes "1,2,#,#,#". Numbers are printed with strconv.Itoa of the integer value.

Write Serialize(root).

Next: Bounded Parallel Map