20. Valid Parentheses
来源:互联网 发布:电脑有网络但上不到网 编辑:程序博客网 时间:2024/05/29 16:36
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.
class Solution {public:bool isValid(string s) {stack<char> stk;for (char h : s){if (stk.empty() || h == '(' || h == '{' || h == '['){stk.push(h);}else{if (h == ')'&&stk.top() == '('){stk.pop();}else if (h == '}'&&stk.top() == '{'){stk.pop();}else if (h == ']'&&stk.top() == '['){stk.pop();}else{stk.push(h);}}}return stk.empty();}};
0 0
- LeetCode 20. Valid Parentheses
- [LeetCode] 20.Valid Parentheses
- LeetCode --- 20. Valid Parentheses
- LeetCode 20.Valid Parentheses
- [Leetcode] 20. Valid Parentheses
- 20.Valid Parentheses
- 20.Valid Parentheses
- 20. Valid Parentheses
- 【leetcode】20. Valid Parentheses
- [leetcode] 20.Valid Parentheses
- [leetcode] 20. Valid Parentheses
- 20. Valid Parentheses
- 20. Valid Parentheses
- 20. Valid Parentheses
- Leetcode 20. Valid Parentheses
- 20. Valid Parentheses LeetCode
- 20. Valid Parentheses
- 20. Valid Parentheses
- ListView里面有EditTextView,解决弹出键盘后EditView不能获取焦点的问题
- ListView里面有EditTextView,解决弹出键盘后EditView不能获取焦点的问题
- Toad for Mysql 连接远程服务器的数据库问题记录
- CSS背景图片路径设置
- perl模块安装
- 20. Valid Parentheses
- 巧用可变参数宏、编译器内置宏和printf输出调试信息
- 0.Intellij IDEA 添加jar包的三种方式
- windows下mysql忘记root密码的解决办法
- Poco库XML文件的生成与解析
- 循环双端队列示例C++_通话列表的保存
- Android 复杂的手势处理利用GestureOverView
- bsdiff 文档翻译
- 他贡献大于爱因斯坦,玩股票能赢过巴菲特