Question d’entretien chez Bloomberg

Write code to keep track of the running minimum in a stack.

Réponse à la question d'entretien

Utilisateur anonyme

22 août 2017

Use a second stack. If a new element pushed onto the stack is less than or equal to the current minimum (the top of the minimum stack), then push the new element onto the minimum stack. If an element is popped off the stack, if it's equal to the item on top of the minimum stack, pop off the top of the minimum stack.

5