UVa 673 - Parentheses Balance

673 - Parentheses Balance

 * http://acm.uva.es/p/v6/673.html

Summary
The task is to check whether a given string contains a properly nested set of parentheses.

Since the language described is a very simple context-free language, we can use a stack to implement the associated push-down automaton.

Explanation
The context-free language in question looks as follows: S -> [S] | (S) | SS | nothing

Input
7 ([]) (([]))) ([[]]) ( (] )( ][

Output
Yes No Yes No No No No