easy
Valid Parentheses
Given a string containing only the characters ()[]{}, decide whether it is well-formed: every opening bracket is closed by the same type in the correct nested order.
Constraints
- 1 ≤ s.length ≤ 10^4
- s consists only of ()[]{}
Examples
in: s = "()[]{}"
out: true
in: s = "([)]"
out: false
Code it yourself
Solve in
Test execution is not yet available for this exercise.Practice journal →Draft saved in this browser.
Hints:
Which approach applies?
Choose an approach to check your pattern recognition, or reveal the discussion when you need help.