Get Minimum, is a Stack related problem and in this post we will see how we can solve this challenge in C++

get the minimum element in constant time keep track of the minimum element using a stack say minStack whenever we get an element smaller or equal to the top of minStack then push the element, During pop if the element is same as the minStack top then pop both

Please check the main.cpp snippet for the solution.

This solution originally posted at: Github by @susantabiswas