Approach hintTry it first, then revealHide
Store with each element the minimum of the stack at the moment it was pushed, for example as pairs. The current minimum is then always on top, and popping restores the previous minimum automatically.
Store with each element the minimum of the stack at the moment it was pushed, for example as pairs. The current minimum is then always on top, and popping restores the previous minimum automatically.