Stack Operations
The fundamental Stack operations are Push, Pop, and Peek. Push adds an element to the top, Pop removes and returns the top element, and Peek returns the top element without removing it.
Push: inserts an element at the top.
Pop: removes and returns the top element.
Peek: reads the top element without modifying the stack.
All three are typically O(1).
Pop and Peek should define behavior for an empty stack, such as returning an error or throwing an exception.
0-2 years experience
2-5 years experience
5-8 years experience
8+ years experience