A stack must support four operations, each in O(1): push x, pop, top (the top value) and get_min (the smallest value in the stack). ops is a list of operations written as text, such as "push 5", "pop", "top" and "get_min".
Run them from an empty stack and return the results of every top and get_min, in order. push and pop give no result. No operation is applied to an empty stack.
For ["push 5", "push 3", "get_min", "pop", "top", "get_min"] the answer is [3, 5, 5].
Example 1
Input:
min_stack(['push 5', 'push 3', 'get_min', 'pop', 'top', 'get_min'])
Output:
[3, 5, 5]
Example 2
Input:
min_stack(['push -2', 'push 0', 'push -3', 'get_min', 'pop', 'top', 'get_min'])
Output:
[-3, 0, -2]
0 <= len(ops) <= 200000-10**9 <= x <= 10**9pop, top and get_min are only used when the stack is not empty.No results yet
Run your code to check it against the examples, or submit to run every test.