Implement a stack such that push(<item>)
, pop()
and
getMinimumValue()
have an amortized complexity of O(1).
push(<item>)
and pop()
have the usual implementation.
getMinimumValue()
returns the minimum value currently stored
in the stack.
For example:
stack.push(5)
stack.push(3)
stack.push(27)
stack.getMinimumValue() => 3