Balanced Expressions
Checking
- Equal numbers of left and right parentheses
- Every right parentheses has a matching right
How?
- Push opening brackets on the stack
- Pop matching brackets of the stack
- If the stack is not empty at the end /we try to pop the empty stack the expression is not balanced