Design a stack that supports push, pop, top, and retrieving the minimum element in constant time.
Implement the MinStack class:
push(val)pushes the element val onto the stack.pop()removes the element on the top of the stack.top()gets the top element of the stack.getMin()retrieves the minimum element in the stack.
You must implement a solution with O(1) time complexity for each function.
Note: For this problem, implement operations as a function that takes a list of commands and returns the results. Return null for void operations (push, pop).