A template string contains only ()[]{}. Return true if every bracket is closed by the same type in the correct order.
Signature
isValid(s: string) → boolExample 1
s = "()[]{}"
output = true
Example 2
s = "([)]"
output = false
closes in the wrong order
Example 3
s = "{[]}"
output = true
Constraints
1 ≤ |s| ≤ 10^4
⌘/Ctrl + Enter runs examples
Run checks the examples. Submit runs every hidden test (17, including large inputs that catch slow solutions).