Pregunta de entrevista de Amazon

Balanced braces, another Tree based question