Pregunta de entrevista de Amazon

Leet code medium problem which required knowledge of trees