mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-09-02 14:12:17 +08:00
update
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
"translatedContent": "<p>设计一个基于时间的键值数据结构,该结构可以在不同时间戳存储对应同一个键的多个值,并针对特定时间戳检索键对应的值。</p>\n\n<p>实现 <code>TimeMap</code> 类:</p>\n\n<ul>\n\t<li><code>TimeMap()</code> 初始化数据结构对象</li>\n\t<li><code>void set(String key, String value, int timestamp)</code> 存储键 <code>key</code>、值 <code>value</code>,以及给定的时间戳 <code>timestamp</code>。</li>\n\t<li><code>String get(String key, int timestamp)</code>\n\t<ul>\n\t\t<li>返回先前调用 <code>set(key, value, timestamp_prev)</code> 所存储的值,其中 <code>timestamp_prev <= timestamp</code> 。</li>\n\t\t<li>如果有多个这样的值,则返回对应最大的 <code>timestamp_prev</code> 的那个值。</li>\n\t\t<li>如果没有值,则返回空字符串(<code>\"\"</code>)。</li>\n\t</ul>\n\t</li>\n</ul>\n \n\n<p><strong>示例:</strong></p>\n\n<pre>\n<strong>输入:</strong>\n[\"TimeMap\", \"set\", \"get\", \"get\", \"set\", \"get\", \"get\"]\n[[], [\"foo\", \"bar\", 1], [\"foo\", 1], [\"foo\", 3], [\"foo\", \"bar2\", 4], [\"foo\", 4], [\"foo\", 5]]\n<strong>输出:</strong>\n[null, null, \"bar\", \"bar\", null, \"bar2\", \"bar2\"]\n\n<strong>解释:</strong>\nTimeMap timeMap = new TimeMap();\ntimeMap.set(\"foo\", \"bar\", 1); // 存储键 \"foo\" 和值 \"bar\" ,时间戳 timestamp = 1 \ntimeMap.get(\"foo\", 1); // 返回 \"bar\"\ntimeMap.get(\"foo\", 3); // 返回 \"bar\", 因为在时间戳 3 和时间戳 2 处没有对应 \"foo\" 的值,所以唯一的值位于时间戳 1 处(即 \"bar\") 。\ntimeMap.set(\"foo\", \"bar2\", 4); // 存储键 \"foo\" 和值 \"bar2\" ,时间戳 timestamp = 4 \ntimeMap.get(\"foo\", 4); // 返回 \"bar2\"\ntimeMap.get(\"foo\", 5); // 返回 \"bar2\"\n</pre>\n\n<p> </p>\n\n<p><strong>提示:</strong></p>\n\n<ul>\n\t<li><code>1 <= key.length, value.length <= 100</code></li>\n\t<li><code>key</code> 和 <code>value</code> 由小写英文字母和数字组成</li>\n\t<li><code>1 <= timestamp <= 10<sup>7</sup></code></li>\n\t<li><code>set</code> 操作中的时间戳 <code>timestamp</code> 都是严格递增的</li>\n\t<li>最多调用 <code>set</code> 和 <code>get</code> 操作 <code>2 * 10<sup>5</sup></code> 次</li>\n</ul>\n",
|
||||
"isPaidOnly": false,
|
||||
"difficulty": "Medium",
|
||||
"likes": 162,
|
||||
"likes": 163,
|
||||
"dislikes": 0,
|
||||
"isLiked": null,
|
||||
"similarQuestions": "[]",
|
||||
@@ -155,7 +155,7 @@
|
||||
"__typename": "CodeSnippetNode"
|
||||
}
|
||||
],
|
||||
"stats": "{\"totalAccepted\": \"23.1K\", \"totalSubmission\": \"43.4K\", \"totalAcceptedRaw\": 23050, \"totalSubmissionRaw\": 43409, \"acRate\": \"53.1%\"}",
|
||||
"stats": "{\"totalAccepted\": \"23.1K\", \"totalSubmission\": \"43.5K\", \"totalAcceptedRaw\": 23065, \"totalSubmissionRaw\": 43454, \"acRate\": \"53.1%\"}",
|
||||
"hints": [],
|
||||
"solution": {
|
||||
"id": "131",
|
||||
|
Reference in New Issue
Block a user