Pergunta de entrevista da empresa Amazon

Q: Question based on generic trees