ALG-M003MediumStack
Bracket Sequence Validator
The input contains only (), [], and {} symbols. Return true when every opening bracket is closed by the matching type in correct nesting order.
Contract
input text: string
return boolean
Constraints
- • Input alphabet is ()[]{}
- • 0 <= length <= 100000
Examples
Example 1
text = "([]{})"
→ true
Example 2
text = "([)]"
→ false
5 judge tests (2 shown above). Target complexity: O(n).