EEasy· stack· string
Valid Parentheses
Valid Parentheses
Given a string s containing only the characters (, ), {, }, [, and ], determine if the string is valid. A string is valid if every open bracket is closed by the same type of bracket, and brackets are closed in the correct order. An empty string is considered valid.
Example
Input: s = "()[]{}" → Output: true
Input: s = "(]" → Output: false
Input: s = "([)]" → Output: false
Input: s = "{[]}" → Output: true
Constraints
- 1 ≤ s.length ≤ 10⁴
sconsists of parentheses characters only:()[]{}.
Entry — isValid
Grading — exact over 5 tests