Min Li's Note
KVM,QEMU, X86 virtualization
Pages
Home
Collection
About
Monday, September 15, 2014
Valid Parentheses
Problem
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.
Idea
依次检查string的每个字符,如果是(,{,[则压入堆栈,如果是),{,]则弹出栈顶元素,并检查是否匹配。
Note
如何遍历string里每个元素
string里的find
c++ Stack 用法
Solution
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment