leetCode(valid-parentheses)-判断括号的合法性
题目:给定一个字符串,字符串中只可能含有'('、')'、'['、']'、’{‘、'}'这些字符,如果括号可以配对,返回true,否则返回false;
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
思路:这是典型的栈问题,采用一个辅助栈就可以完成