Min-max stack

Write codeMedium25 minBloomberg style

Your task

Implement a stack that supports push(x), pop(), and two O(1) queries: get_min() returning the minimum of all elements currently on the stack, and get_max() returning the maximum. Replay a list of operations; each op is ["push", x], ["pop"], ["min"], or ["max"]. Return the list of results produced by pop/min/max ops in order (pop returns the popped value). Assume min/max/pop are never called on an empty stack.

Examples

minmax_stack(ops: list[list]) -> list[int]
Example 1
Inputminmax_stack([["push", 5], ["push", 2], ["min"], ["max"], ["push", 8], ["max"], ["pop"], ["min"]])
Output[2, 5, 8, 8, 2]