Question d’entretien chez Amazon

how to display a minimum value in stack with constant time complexity

Réponse à la question d'entretien

Utilisateur anonyme

16 mai 2013

Initialize minValue In each insertion into stack, check if the value to be inserted is less than minValue, if so, set minValue to the new value, insert_into_stack This way, the minValue will always be ready and can get it in constant time.