Perfios Software interview question

Balancing parenthesis