Skip to content

Stacks perform getmin in O(1) operation

Devrath edited this page Jul 27, 2021 · 3 revisions

PROBLEM STATEMENT: We are having a stack of integers, Now we need to have a function that returns the minimum value in the stack and this should hold in case of push and pop operations are done

Algorithm:

  • Assume there are 4 elements in stack 8-10-3-7

Clone this wiki locally