mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-09-02 22:13:28 +08:00
update
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
"translatedContent": "<p>一家社交媒体公司正试图通过分析特定时间段内出现的推文数量来监控其网站上的活动。这些时间段可以根据特定的频率( <strong>每分钟 </strong>、<strong>每小时 </strong>或 <strong>每一天</strong> )划分为更小的 <strong>时间段</strong> 。</p>\n\n<p> </p>\n\n<p>例如,周期 <code>[10,10000]</code> (以 <strong>秒</strong> 为单位)将被划分为以下频率的 <strong>时间块</strong> :</p>\n\n<ul>\n\t<li>每 <strong>分钟</strong> (60秒 块):<meta charset=\"UTF-8\" /> <code>[10,69]</code>, <code>[70,129]</code>, <code>[130,189]</code>, <code>...</code>, <code>[9970,10000]</code></li>\n\t<li>每 <strong>小时</strong> (3600秒 块):<meta charset=\"UTF-8\" /><code>[10,3609]</code>, <code>[3610,7209]</code>, <code>[7210,10000]</code></li>\n\t<li>每 <strong>天</strong> (86400秒 块):<meta charset=\"UTF-8\" /> <code>[10,10000]</code></li>\n</ul>\n\n<p>注意,最后一个块可能比指定频率的块大小更短,并且总是以时间段的结束时间结束(在上面的示例中为 <code>10000</code> )。</p>\n\n<p>设计和实现一个API来帮助公司进行分析。</p>\n\n<p>实现 <code>TweetCounts</code> 类:</p>\n\n<ul>\n\t<li><code>TweetCounts()</code> 初始化 <code>TweetCounts</code> 对象。</li>\n\t<li>存储记录时间的 <code>tweetName</code> (以秒为单位)。</li>\n\t<li><code>List<integer> getTweetCountsPerFrequency(String freq, String tweetName, int startTime, int endTime)</code> 返回一个整数列表,表示给定时间 <code>[startTime, endTime]</code> (单位秒)和频率频率中,每个 <strong>时间块</strong> 中带有 <code>tweetName</code> 的 <code>tweet</code> 的数量。\n\t<ul>\n\t\t<li><code>freq</code> 是 <code>“minute”</code> 、 <code>“hour”</code> 或 <code>“day”</code> 中的一个,分别表示 <strong>每分钟</strong> 、 <strong>每小时</strong> 或 <strong>每一天</strong> 的频率。</li>\n\t</ul>\n\t</li>\n</ul>\n\n<p> </p>\n\n<p><strong>示例:</strong></p>\n\n<pre>\n<strong>输入:</strong>\n[\"TweetCounts\",\"recordTweet\",\"recordTweet\",\"recordTweet\",\"getTweetCountsPerFrequency\",\"getTweetCountsPerFrequency\",\"recordTweet\",\"getTweetCountsPerFrequency\"]\n[[],[\"tweet3\",0],[\"tweet3\",60],[\"tweet3\",10],[\"minute\",\"tweet3\",0,59],[\"minute\",\"tweet3\",0,60],[\"tweet3\",120],[\"hour\",\"tweet3\",0,210]]\n\n<strong>输出:</strong>\n[null,null,null,null,[2],[2,1],null,[4]]\n\n<strong>解释:</strong>\nTweetCounts tweetCounts = new TweetCounts();\ntweetCounts.recordTweet(\"tweet3\", 0);\ntweetCounts.recordTweet(\"tweet3\", 60);\ntweetCounts.recordTweet(\"tweet3\", 10); // \"tweet3\" 发布推文的时间分别是 0, 10 和 60 。\ntweetCounts.getTweetCountsPerFrequency(\"minute\", \"tweet3\", 0, 59); // 返回 [2]。统计频率是每分钟(60 秒),因此只有一个有效时间间隔 [0,60> - > 2 条推文。\ntweetCounts.getTweetCountsPerFrequency(\"minute\", \"tweet3\", 0, 60); // 返回 [2,1]。统计频率是每分钟(60 秒),因此有两个有效时间间隔 <strong>1)</strong> [0,60> - > 2 条推文,和 <strong>2)</strong> [60,61> - > 1 条推文。 \ntweetCounts.recordTweet(\"tweet3\", 120); // \"tweet3\" 发布推文的时间分别是 0, 10, 60 和 120 。\ntweetCounts.getTweetCountsPerFrequency(\"hour\", \"tweet3\", 0, 210); // 返回 [4]。统计频率是每小时(3600 秒),因此只有一个有效时间间隔 [0,211> - > 4 条推文。\n</pre>\n\n<p> </p>\n\n<p><strong>提示:</strong></p>\n\n<ul>\n\t<li><code>0 <= time, startTime, endTime <= 10<sup>9</sup></code></li>\n\t<li><code>0 <= endTime - startTime <= 10<sup>4</sup></code></li>\n\t<li><code>recordTweet</code> 和 <code>getTweetCountsPerFrequency</code>,最多有<meta charset=\"UTF-8\" /> <code>10<sup>4</sup></code> 次操作。</li>\n</ul>\n",
|
||||
"isPaidOnly": false,
|
||||
"difficulty": "Medium",
|
||||
"likes": 24,
|
||||
"likes": 25,
|
||||
"dislikes": 0,
|
||||
"isLiked": null,
|
||||
"similarQuestions": "[]",
|
||||
@@ -161,7 +161,7 @@
|
||||
"__typename": "CodeSnippetNode"
|
||||
}
|
||||
],
|
||||
"stats": "{\"totalAccepted\": \"3.9K\", \"totalSubmission\": \"12.3K\", \"totalAcceptedRaw\": 3926, \"totalSubmissionRaw\": 12277, \"acRate\": \"32.0%\"}",
|
||||
"stats": "{\"totalAccepted\": \"4K\", \"totalSubmission\": \"12.5K\", \"totalAcceptedRaw\": 4024, \"totalSubmissionRaw\": 12506, \"acRate\": \"32.2%\"}",
|
||||
"hints": [],
|
||||
"solution": null,
|
||||
"status": null,
|
||||
|
Reference in New Issue
Block a user