Binary Tree to String and Back

Asked at Amazon · Coding Questions · Difficulty: Hard

Build a converter that turns a binary tree of integers into a single string and turns that string back into the same tree. This is how a tree is saved to a file or sent over a network: only the string travels, so it must carry the whole shape, including where children are missing. You choose the string format.

Loading the problem…