Question d’entretien chez HyperVerge

"Design a function to find the maximum element in a stack in O(1) time."

Réponse à la question d'entretien

Utilisateur anonyme

28 août 2024

To answer this question, you could use an additional data structure, such as a min-heap, to store the maximum element as you push and pop elements in the stack. This way, you can access the maximum element in O(1) time. If you have a specific interview question or topic in mind, please let me know, and I'll be happy to help!