4. Balanced Brackets
easystackstring
Given a string s made only of the characters ()[]{}, decide whether every bracket is closed by the same type of bracket and in the correct order.
Example 1
Inputs = "()"
Outputtrue
Example 2
Inputs = "()[]{}"
Outputtrue
Example 3
Inputs = "(]"
Outputfalse
Example 4
Inputs = "([{}])"
Outputtrue
Constraints
- 1 ≤ s.length ≤ 10⁴
Hint 1
Push openers onto a stack, and pop when you see a closer.