<aside> 💡 Dumb and possibly pretty stressful queue for the real world but really important when it comes to programming
</aside>
Here, the last element always comes out first, so to speak, the ones on top.
<aside> 💡 Stack
</aside>
Imagine you have a stack of plates. Which one would you grab first? If you don’t feel like breaking some of them, you’d probably reach for the one on top.
The "parenthesis problem" typically refers to the task of determining whether a given expression has balanced parentheses. In other words, you need to check if every opening parenthesis has a corresponding closing parenthesis, and they are properly nested. For example, the expressions "(())" and "(()())" are balanced, while "())(" is not.
One way to solve this problem is by using a data structure called a stack. A stack is a Last In, First Out (LIFO) data structure, where elements are added and removed from the same end, usually called the "top" of the stack.
Here's a general approach to solving the balanced parentheses problem using a stack: