Pregunta de entrevista de Adobe

Tree based easy question from LC