Implementing Stack with GetMin operation
In this post we discuss how to efficiently implement a stack data structure with one additional operation getMin() along with push() and pop(). getMin() returns the minimum value in the stack. The trick here is to use another stack which stores the minimum values of the original stack. The top of Min-stack always contains the…