Stack min max queries
Your task
Design a stack that, in addition to push and pop, can report the current minimum AND current maximum in O(1) time. Simulate it: given a list of operations where each op is ['push', x], ['pop'], ['min'], or ['max'], return the list of results produced by the 'min' and 'max' queries in order. 'pop' on the described sequence is always valid. Values fit in 32-bit signed integers.
Examples
min_max_stack(ops: list[list]) -> list[int]Example 1
Input
min_max_stack([["push", 5], ["push", 2], ["min"], ["max"], ["push", 8], ["max"], ["pop"], ["max"]])Output
[2, 5, 8, 5]