Leetcode Problem.20—Valid Parentheses
来源:互联网 发布:linux 进程逻辑地址 编辑:程序博客网 时间:2024/06/05 03:46
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.
My C++ solution!
bool isValid(string s){int len=s.length();if(len%2)return false;stack<char> st;int i=1;st.push(s[0]); while(i<len){if(st.empty())st.push(s[i]);else {if(s[i]-st.top()>2||s[i]-st.top()<1)st.push(s[i]); elsest.pop();}i++;}return st.size()==0?true:false;}
0 0
- Leetcode Problem.20—Valid Parentheses
- 【Leetcode problem 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
- 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
- android_使用Gson解析json数据
- String的面试题-==和equals
- MySQL 中文乱码
- win7环境配置VC++6.0,让你的IDE飞起来
- ios各种证书相关
- Leetcode Problem.20—Valid Parentheses
- POJ1337---A Lazy Worker(dp)
- PC-Lint安装配置与集成到VS2010
- postgreSQL在ubuntu环境下的安装使用
- CentOS6.5安装Python 2.7
- Application.mk语法解释
- python2.7+pip+virtualenv
- java 内存分配和String类型的深度解析
- IOS多语言环境自由切换