Pergunta de entrevista da empresa Yahoo

Tree based Leet code style question