Amazon interview question

build a tree from string