Pregunta de entrevista de Amazon

Tree Based Question and One basic Math's.