← 返回题库
中级

LRU 缓存

未完成
中级参考 代码结构已给出,请填写 ____ 处
class LRUCache:
    def __init__(____):
        self.cap = capacity
        self.cache = {}
    def get(____):
        return self.cache.get(____)
    def put(____):
        self.cache[key] = value

示例

输入
LRUCache(2); put(1,1); put(2,2); get(1)
期望输出
1
Python 代码 🔒 登录后使用
🔒

登录后即可练习

注册免费账号,在浏览器中直接运行 Python 代码