[leetcode]20. Valid Parentheses
来源:互联网 发布:手机看书软件免费下载 编辑:程序博客网 时间:2024/06/05 14:26
题目链接:https://leetcode.com/problems/valid-parentheses/
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) { unordered_map<char, char> map; map['(']=')'; map['{']='}'; map['[']=']'; stack<char> charStack; for(int i=0;i<s.length();i++) { if(map.find(s[i])!=map.end()) charStack.push(s[i]); else { if(!charStack.empty()&&map[charStack.top()]==s[i]) charStack.pop(); else return false; } } return charStack.empty(); }};
0 0
- LeetCode 20. Valid Parentheses
- [LeetCode] 20.Valid Parentheses
- LeetCode --- 20. Valid Parentheses
- LeetCode 20.Valid Parentheses
- [Leetcode] 20. Valid Parentheses
- 【leetcode】20. Valid Parentheses
- [leetcode] 20.Valid Parentheses
- [leetcode] 20. Valid Parentheses
- Leetcode 20. Valid Parentheses
- 20. Valid Parentheses LeetCode
- leetcode 20. Valid Parentheses
- 【LeetCode】20. Valid Parentheses
- leetcode 20. Valid Parentheses
- leetcode 20. Valid Parentheses
- LeetCode-20.Valid Parentheses
- LeetCode *** 20. Valid Parentheses
- LeetCode 20. Valid Parentheses
- leetcode-20. Valid Parentheses
- wemall doraemon中Android app商城系统工具集合类,包含各种程序中用到的静态方法
- Android平台下APP唤醒机制
- bzoj 2500: 幸福的道路 动态规划+单调栈
- 多种方式实现Sigmoid函数导数的仿真(含代码)
- 服务端与客户端存储形式之登录方式演变
- [leetcode]20. Valid Parentheses
- 微信jsapi开发教程之微信jsapi与java初步接入(第四课)
- Android 命名规范
- NDK开发的奇技淫巧(一)
- 快乐的实现单独页面横屏
- asp.net创建webapi
- mac 下配置adb环境变量
- Ajax获取数据的流程
- poj 1682