← 返回 snowflake 的题目列表Valid Parentheses
类型:qbank
You are given a string s consisting of the following characters: '(', ')', '{', '}', '[' and ']'.
Problem Overview
You are given a string s. This string is built using only these characters: '(', ')', '{', '}', '[' and ']'.
To consider the string valid, it must follow these three rules:
Open brackets must be closed by the matching type of bracket.
Brackets must be closed in the correct order.
Every closing bracket must have a matching opening bracket.
Your task is to return true if the string meets these rules, and false if it does not.
Sample Inputs & Outputs
Case 1:
Input: s = "[]"
Output: true
Case 2:
Input: s = "([{}])"
Output: true
Case 3:
Input: s = "[(])"
Output: false
Explanation for Case 3:
The brackets do not close in the right order. The [ is incorrectly closed by ) instead of ].
Input Limits
The length of string s is between 1 and 10,000.
The string s contains only parenthesis characters: ()[]{}.