mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-10-25 06:48:57 +08:00
update
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
"translatedContent": "<p>设计和构建一个“最近最少使用”缓存,该缓存会删除最近最少使用的项目。缓存应该从键映射到值(允许你插入和检索特定键对应的值),并在初始化时指定最大容量。当缓存被填满时,它应该删除最近最少使用的项目。</p>\n\n<p>它应该支持以下操作: 获取数据 <code>get</code> 和 写入数据 <code>put</code> 。</p>\n\n<p>获取数据 <code>get(key)</code> - 如果密钥 (key) 存在于缓存中,则获取密钥的值(总是正数),否则返回 -1。<br>\n写入数据 <code>put(key, value)</code> - 如果密钥不存在,则写入其数据值。当缓存容量达到上限时,它应该在写入新数据之前删除最近最少使用的数据值,从而为新的数据值留出空间。</p>\n\n<p><strong>示例:</strong></p>\n\n<pre>LRUCache cache = new LRUCache( 2 /* 缓存容量 */ );\n\ncache.put(1, 1);\ncache.put(2, 2);\ncache.get(1); // 返回 1\ncache.put(3, 3); // 该操作会使得密钥 2 作废\ncache.get(2); // 返回 -1 (未找到)\ncache.put(4, 4); // 该操作会使得密钥 1 作废\ncache.get(1); // 返回 -1 (未找到)\ncache.get(3); // 返回 3\ncache.get(4); // 返回 4\n</pre>\n",
|
||||
"isPaidOnly": false,
|
||||
"difficulty": "Medium",
|
||||
"likes": 148,
|
||||
"likes": 151,
|
||||
"dislikes": 0,
|
||||
"isLiked": null,
|
||||
"similarQuestions": "[]",
|
||||
@@ -155,7 +155,7 @@
|
||||
"__typename": "CodeSnippetNode"
|
||||
}
|
||||
],
|
||||
"stats": "{\"totalAccepted\": \"37.9K\", \"totalSubmission\": \"69.3K\", \"totalAcceptedRaw\": 37933, \"totalSubmissionRaw\": 69327, \"acRate\": \"54.7%\"}",
|
||||
"stats": "{\"totalAccepted\": \"39K\", \"totalSubmission\": \"71.2K\", \"totalAcceptedRaw\": 38976, \"totalSubmissionRaw\": 71221, \"acRate\": \"54.7%\"}",
|
||||
"hints": [
|
||||
"首先明确问题。你到底想要什么功能?",
|
||||
"什么数据结构对查找最有用?维护元素顺序最有用的数据结构是什么?",
|
||||
|
||||
Reference in New Issue
Block a user