Amazon interview question

Binary tree style question