Dashboard
LC #20
Valid Parentheses
Pattern · ?
Problem
Given a string containing just (, ), {, }, [ and ], determine if the input string is valid.
Constraints
- 1 ≤ s.length ≤ 10⁴
- s consists of parentheses only ().
Example
- Input
- s = "()[]{}"
- Output
- true
- Why
- All brackets are closed in the correct order by the same type of brackets.
Spot the pattern
Which pattern cracks it?
Hints
One at a time