LeetCode - Valid Parentheses

Reduction problem in compiling principle.

Data Structure: stack

STL - stack:

  http://www.cplusplus.com/reference/stack/stack/

  http://sunzhongfang22.blog.163.com/blog/static/33856090201152451347642/

Solver:

  1. when encounters a pre-bracket, push it to the stack;

  2. when encounters a post-bracket, pop the stack and compare with it.

Attention to some special inputs.

 

posted on 2013-04-14 16:13  highstar88  阅读(91)  评论(0编辑  收藏  举报

导航