[DAY 28]Balanced Brackets
1 min readDec 3, 2019
[Solution] Stack
Using stack to record the brackets. Each time when we get a closing bracket we would check if the stack is empty. If not, we pop the last element of the stack and check if the popped bracket matched the closing bracket we just got. Otherwise, we would just push the bracket into the stack. In the end, if the stack is not empty means this string contains imbalanced brackets.