Example 1
Input
s = "()[]{}"Output
true
Each opening bracket is closed in a valid order.
Loading CodeSprint...
/problems/valid-parentheses
Determine whether every opening bracket in a string is closed by the matching bracket in the correct nested order. The string may contain parentheses, square brackets, and braces.
Implement this function and return the result. CodeSprint supplies each test case automatically.
isValid(s) → booleanInput
s = "()[]{}"Output
true
Each opening bracket is closed in a valid order.
Input
s = "([)]"
Output
false
The closing order crosses between bracket types.
Constraints
0 <= s.length <= 100,000
s contains only the characters ( ) [ ] { }.