Amazon interview question

Binary tree algorithm question.