Pergunta de entrevista da empresa JWP (JW Player)

How you write a program to balance parentheses?