Design a stack of numbers with push, pop, top, peekMin, peekMax, popMin and popMax, driven as an operation list: run(ops, args) applies each operation with its own argument list and returns one result per operation. pop and top use the most recent surviving push; popMin and popMax remove and return the smallest or largest value, taking the copy nearest the top when values tie; push, and every operation on an empty stack, return null. For push 5, push 1, push 5, peekMax, popMax, top, popMin, pop the results are [null,null,null,5,5,1,1,5]. Up to 100,000 operations are run in order.
The run(ops, args) helper is already written: it builds the stack from the first operation and calls the methods for the rest, like LeetCode's operation lists. Fill in the class.