leetcode 20 简单括号匹配
2016-09-28 14:55
453 查看
栈的运用
class Solution { public: bool isValid(string s) { stack<char>The_Stack; int i=0; The_Stack.push('#'); while(i<s.size()) { if((s[i]==')'&&The_Stack.top()=='(')||(s[i]==']'&&The_Stack.top()=='[')||(s[i]=='}'&&The_Stack.top()=='{')) { i++; The_Stack.pop(); } else { The_Stack.push(s[i]); i++; } } if(The_Stack.top()=='#') return true; return false; } };
相关文章推荐
- LeetCodet题解--20. Valid Parentheses(括号匹配问题)
- LeetCode20——Valid Parentheses(括号匹配问题,使用栈的知识)
- Leetcode刷题记——20. Valid Parentheses (有效的括号即括号匹配)
- LeetCode 20 Valid Parentheses (括号匹配问题)
- leetcode 20 Valid Parentheses 括号匹配
- leetcode 20 Valid Parentheses 括号匹配
- LeetCode 20 Valid Parentheses(括号匹配)
- leetcode 20 括号匹配
- Leetcode 20 Valid Parentheses 判断括号匹配
- leetcode_20. Valid Parentheses 括号匹配问题;java String实例的声明和初始化;没用栈;
- leetcode 20 Valid Parentheses 括号匹配
- LeetCode 20 Valid Parentheses 括号匹配问题
- LeetCode 20 Valid Parentheses(用栈判断括号匹配)
- 简单的括号匹配
- LeetCode | Valid Parentheses(括号匹配)
- 模拟 --- 简单括号匹配
- LeetCode | Longest Valid Parentheses(最长有效的括号匹配)
- UVA 11584 (简单DP,类似括号匹配)
- leetcode 括号匹配系列
- Lettcode_20_Valid Parentheses——括号匹配算法