Given a string containing just the characters ‘(‘
, ‘)‘
, ‘{‘
, ‘}‘
, ‘[‘
and ‘]‘
,
determine if the input string is valid.
The brackets must close in the correct order, "()"
and "()[]{}"
are
all valid but "(]"
and "([)]"
are
not.
1)stack<char>的数据结构,stk.push(elem),stk.pop(),stk.top等用法。
2)栈为空,输入为左括弧,输入为右括弧,分不同情况讨论,入栈,出栈,退出,continue等
class Solution {
public:原文地址:http://blog.csdn.net/shahongzhou/article/details/40383481