LinkedIn interview question

Build the tree from bottom to top