Problem 673
-- Parentheses Balance
read problem
Tips
A question that can be solved by a simple
stack.
- Read each char in a string.
- If the char is a opening or closing
parenthese, push.
- After each push, check whether the
top two elements on stack are a pair. If yes, pop them
out.
- When a string is finished, if the
stack is empty the parentheses are balance.
The (a) to (c) description in the problem
are none-sense. Simply ignore them.