Pergunta de entrevista da empresa Google

How would you implement a stack to achieve constant time for "push", "pop" and "find mininum" operations?

Respostas da entrevista

Sigiloso

15 de mai. de 2010

The catch is to use another stack to remember the minimum. The other operations already take constant time.

1

Sigiloso

12 de ago. de 2014

With an array you can implement in Push/Pop in constant time. The expansion/contraction of the array can be implemented such that the amortized cost is constant.