AApple·DSASDE-1Online Assessment
Valid Parentheses
Problem
Given a string containing ()[]{}, determine if the input is valid — brackets closed in the correct order.
Example
s = "([{}])"
Output: true
s = "([)]"
Output: false
Constraints
- 1 ≤ s.length ≤ 10^4
Approach
Stack: push openers, pop and match on closers. Reject if the stack is non-empty at the end.
added 6 days ago