Given a string
s containing characters ()[]{}. Determine whether the input string is valid.Example 1
Input: s = "(]"
Output: False
Explanation: The closing bracket type does not match the last opening bracket.
Output: False
Explanation: The closing bracket type does not match the last opening bracket.
Example 2
Input: s = "()"
Output: True
Explanation: The opening bracket is closed correctly in the proper order.
Output: True
Explanation: The opening bracket is closed correctly in the proper order.
Example 3
Input: s = "()[]{}"
Output: True
Explanation: Each pair of brackets is valid and the pairs do not overlap.
Output: True
Explanation: Each pair of brackets is valid and the pairs do not overlap.