A stack is a data structure that holds a list of elements. A stack works based on the LIFO principle i.e., Last In, First out, meaning that the most recently added element is the first one to remove. A stack has two main operations that occur only at the top of the stack: push and pop
Push operation
The push operation places an element at the top of stack.
Pop operation
Pop operation removes an element from the top of the stack.