Microsoft interview question

Implement stack that holds minimum

Interview Answer

Anonymous

Feb 1, 2019

Stack has global minimum, each node has minimum. Whenever you push node, nodes minimum = stacks global minimum. That way when you pop, the stacks global minimum = min(top node min, stack min)