easyArrays & Hashing
Valid Parentheses
## Problem
Given a string `s` containing only the characters `(`, `)`, `{`, `}`, `[` and `]`, determine if the input string is **valid**.
A string is valid if:
- Open brackets must be closed by the same type of bracket.
- Open brackets must be closed in the correct order.
- Every close bracket has a corresponding open bracket.
Given a string `s` containing only the characters `(`, `)`, `{`, `}`, `[` and `]`, determine if the input string is **valid**.
A string is valid if:
- Open brackets must be closed by the same type of bracket.
- Open brackets must be closed in the correct order.
- Every close bracket has a corresponding open bracket.
Examples
Input
s = "()[]{}"
Output
true
Input
s = "(]"
Output
false
Input
s = "([)]"
Output
false
Constraints
1 <= s.length <= 10^4
s consists of parentheses only
Python
Loading...