Codesmith interview question

They asked me the balancing brackets question