Yahoo interview question

Tree based Leet code style question