575. Valid Parentheses (Multiple Types)

EasyStackStackString

Given a string s containing the bracket characters '()[]{}', determine whether it is valid — every opening bracket is closed by the same type in the correct order. Return true or false. The input is JSON {s}.

Input: JSON {s}.

Output: Boolean — true or false.

Examples

Example 1
Input: {"s":"()[]{}"}
Output: true
Explanation: All brackets matched by type.
Example 2
Input: {"s":"(]"}
Output: false
Explanation: Mismatched types.
Example 3
Input: {"s":"([)]"}
Output: false
Explanation: Wrong nesting order.

Constraints

Asked by

BloombergHCLTechIBMDeloitteAmazonMeta
Solve this problem in the editor →