Leverage Edu interview question

Stack based balanced paranthesis, easy followup