Stack
LC #20Easy
Valid Parentheses
Stack
Problem
Given a string containing just (, ), {, }, [ and ], determine if the input string is valid.
stringstack
Constraints
- ›1 ≤ s.length ≤ 10⁴
- ›s consists of parentheses only ().
Example
Input
s = "()[]{}"Output
trueWhy
All brackets are closed in the correct order by the same type of brackets.