UVa 673 - Parentheses Balance

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

Gotchas
There are spaces in the input consider it. For a C++ implementation, be careful to use 'cin.ignore' after reading the initial integer. Doing so will allow 'getline' to properly read the following strings, including the blank lines.

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

Output
Yes No Yes No No No No