[leetcode #20 stack]Valid Parentheses
来源:互联网 发布:c语言|是什么 编辑:程序博客网 时间:2024/05/21 11:13
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> st; for(int i=0;i<s.size();i++) { if(s.at(i) == '('){st.push(')');} else if(s.at(i) == '{'){st.push('}');} else if(s.at(i) == '['){st.push(']');} else { if(true == st.empty() || s.at(i)!=st.top()){return false;} else{st.pop();} } } return st.empty()?true:false; }};
0 0
- [leetcode #20 stack]Valid Parentheses
- LeetCode[stack]: Valid Parentheses
- [Leetcode] 20. Valid Parentheses(Stack)
- 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
- 详解Objective-C runtime
- 15-03-14读书笔记
- GUI Programming Using Tkinter
- Android环境搭建——执行SDK Manager.exe无反应
- CBO之B*Tree Index Range Scan - IRS算法
- [leetcode #20 stack]Valid Parentheses
- String类
- ListView的子项中包含EditText,由于复用引起的Editext中的内容显示异常的解决方案
- POJ 3268 Silver Cow Party(dijkstra求单源最短路)
- 发展
- 关于Eclipse的Android项目,在直接运行可以,打包安装就报错,说某个类不存在的解决
- Java环境变量的作用和设置
- Scala-4 - 3 - Lecture 3.3 - Polymorphism (21_09)
- 1036. 跟奥巴马一起编程(15)