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.
本文介绍了一种Least Recently Used (LRU) 缓存的数据结构设计与实现方法。该缓存支持get和set两种操作:get用于获取指定键对应的值;set用于设置或插入键值对。当缓存容量达到上限时,会移除最近最少使用的项以腾出空间。
776

被折叠的 条评论
为什么被折叠?



