20. Valid Parentheses
题目
给定一个仅包含字符 ‘(’, ‘)’, ‘{’, ‘}’, ‘[’ 和 ‘]’ 的字符串,判断输入字符串是否有效。
一个输入字符串是有效的,当满足以下条件时:
左括号必须用相同类型的右括号闭合。
左括号必须以正确的顺序闭合。
注意:空字符串可被认为是有效的。
Example 1:
Input: "()"
Output: true
Example 2:
Input: "()[]{}"
Output: true
Example 3:
Input: "(]"
Output: false
Example 4:
Input: "([)]"
Output: false
Example 5:
Input: "{[]}"
Output: true
题目大意
括号匹配问题