UVa 673
From Algorithmist
Contents |
[edit] 673 - Parentheses Balance
[edit] 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.
[edit] Explanation
The context-free language in question looks as follows:
S -> [S] | (S) | SS | nothing
[edit] Notes
Read the input line by line, the problem statement silently allows empty rows in the input.
[edit] Input
7 ([]) (([()]))) ([()[]()])() ( (] )( ][
[edit] Output
Yes No Yes No No No No

