Amazon interview question

some binary tree related