Pergunta de entrevista da empresa Amazon

some medium-difficulty binary tree problem