20 Valid Parentheses
1. Question
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.
2. Implementation
思路:查看括号匹配问题,就看相应的符号是否对称,可以直接用stack做
3. Time & Space Complexity
时间和空间都是O(n)
Last updated