CDK Global interview question

Balancing brackets code