Back to Questions

Implement an All $O(1)$ Data Structure with Frequency

95.1K viewsAsked at Stripe
Hard

Question Explain

Design a data structure that supports `inc(key)`, `dec(key)`, `getMaxKey()`, and `getMinKey()` in $O(1)$ time. This requires combining multiple Doubly Linked Lists, where each list holds keys of the same frequency, and a Hash Map.

Start Trying This Question Simulation

Practice answering orally or with text to get instant AI feedback.

Practice with This Question
Implement an All $O(1)$ Data Structure with Frequency - Interview Question