📝 Coding_Interviews

LRU Cache (LeetCode 146) Design in Python and Java

BLOG ARTICLE Published on December 3, 2026

Written by Anurag Goel

Source: DEV Community - LeetCode 1 min read intermediate

Summary

This article first appeared on AlgoSimplified. That URL is canonical. The full lesson has the complete Java class, follow-up sketches, exercises and a short quiz. This is a shorter cut of the same design. The problem A cache with fixed capacity. get(key) returns the value (or a miss) and marks the key as recently used. put(key, value) inserts or updates; if the cache is full, it evicts the least recently used key. Both operations must be O(1). A hash map gives O(1) lookup but no ...

#python #java #leetcode #programming
0 views
0 likes
0 comments