Challenge: min() Function Using a Stack
Using your knowledge, create an efficient min() function using a stack.
We'll cover the following
You have to implement the
minStack class, which will have a
min() function. Whenever
min() is called, the minimum value of the stack is returned in O(1) time. The element is not popped from the stack; its value is simply returned.
Returns minimum number in O(1) time
//minStack = [9, 3, 1, 4, 2, 5] //minStack.min() 1