Junior — Senior
Stack that can quickly find the minimum
livecode
Task condition
It is necessary to create a data structure called 'stack' that supports four operations:
- push(x) — add element x to the stack;
- pop() — remove the element at the top of the stack;
- top() — return the current top element without removing it;
- get_min() — return the smallest value among all elements in the stack. All these operations should work in constant time O(1).