Pergunta de entrevista da empresa Microsoft

Given a Stack with n elements, write a method that always keeps the max of the stack?

Resposta da entrevista

Sigiloso

26 de fev. de 2015

Every data structure you may think of for say linked list or an array list etc.. gives us an O(n) runtime but if we create another stack and only push when a higher element comes in then that enables us to have O(1) runtime.

2