NeetCode #338LC-146MediumLinked ListNC 150NC 250
← Back to All Problems#338 · #146 · LRU Cache(LRU 缓存)
📌 Problem Statement & Constraints
Design a Least Recently Used (LRU) cache with a fixed capacity. Implement
get(key) returning the value or -1, and put(key, value). Both must run in O(1) average time. When the capacity is exceeded, evict the least recently used key. Constraints: 1 <= capacity <= 3000; at most 2 * 10^5 calls.🔒
Sign In to Unlock Full Solutions for All 973 Problems
Sign in to access step-by-step logic, benchmark Python3 code, complexity breakdown, and offline export!