Skip to main content
Admissions guidance, study banks, and career tools — get started on Shalyam

Design LFU Cache

Design a cache with capacity cap supporting get k and put k v. When full, put evicts the least frequently used key; ties are broken by evicting the least recently used among them. A get miss prints -1.

Constraints

1 <= cap <= 10^4 O(1) per operation expected

Discussion

No discussions yet.

Rewards · v2.1

Get Exclusive Insights with Every Issue

Join Shalyam Newsletter

Stay ahead in education, research, and innovation—straight to your inbox.