โ† Hike questions

Retrieve maximum, second max, and k-th largest in a stack in O(1)

Filed under Hike

The question

Design a stack that supports push, pop, and retrieving the maximum and second maximum elements in O(1) time. Further extend the design to retrieve the k-th largest element in O(1) time.

No write-up yet. Related questions below have one.

Related Hike questions

Collected from public candidate posts and coding forums. Updated Nov 2026.