673 - Parentheses Balance
The task is to check whether a given string contains a properly nested set of parentheses.
The context-free language in question looks as follows:
S -> [S] | (S) | SS | nothing
Read the input line by line, the problem statement silently allows empty rows in the input.
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.
8 ( ) (([()]))) ([()()])() ( (] )( ][ ([)]
Yes No Yes No No No No No