LeetCode 146 LRU Cache
Posted jzssuanfa
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了LeetCode 146 LRU Cache相关的知识,希望对你有一定的参考价值。
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.
以上是关于LeetCode 146 LRU Cache的主要内容,如果未能解决你的问题,请参考以下文章
LeetCode Top 100 Liked Questions 146. LRU Cache (Java版; Medium)