题目:给定一个字符串,字符串中只可能含有'('、')'、'['、']'、’{‘、'}'这些字符,如果括号可以配对,返回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

思路:这是典型的栈问题,采用一个辅助栈就可以完成

leetCode(valid-parentheses)-判断括号的合法性

相关文章:

  • 2022-02-09
  • 2021-06-28
  • 2021-09-08
  • 2021-04-07
  • 2022-12-23
  • 2021-10-23
  • 2022-02-14
  • 2021-08-10
猜你喜欢
  • 2021-06-30
  • 2021-09-27
  • 2022-01-07
  • 2022-12-23
  • 2022-02-23
  • 2021-10-09
  • 2021-07-25
相关资源
相似解决方案