Amazon interview question

some medium-difficulty binary tree problem