LRU Cache

来源:互联网 发布:电脑系统优化 编辑:程序博客网 时间:2024/05/24 03:20
Design and implement a data structure for Least Recently Used (LRU) cache. It should support the

following operations: get and set.

get(key) - Get the value (will always be positive) of the key if the key exists in the cache, otherwise
return -1.
set(key, value) - Set or insert the value if the key is not already present. When the cache reached its
capacity, it should invalidate the least recently used item before inserting a new item.

0 0
原创粉丝点击