Problem 673 -- Parentheses Balance

read problem

Tips

A question that can be solved by a simple stack.

  1. Read each char in a string.
  2. If the char is a opening or closing parenthese, push.
  3. After each push, check whether the top two elements on stack are a pair. If yes, pop them out.
  4. 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.