1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-09-02 22:13:28 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
This commit is contained in:
2022-05-02 23:44:12 +08:00
parent 7ea03594b3
commit 2a71c78585
4790 changed files with 11696 additions and 10944 deletions

View File

@@ -12,7 +12,7 @@
"translatedContent": "<p>一家社交媒体公司正试图通过分析特定时间段内出现的推文数量来监控其网站上的活动。这些时间段可以根据特定的频率(&nbsp;<strong>每分钟&nbsp;</strong>、<strong>每小时&nbsp;</strong>或 <strong>每一天</strong> )划分为更小的 <strong>时间段</strong> 。</p>\n\n<p>&nbsp;</p>\n\n<p>例如,周期 <code>[10,10000]</code>&nbsp;(以 <strong>秒</strong> 为单位)将被划分为以下频率的 <strong>时间块</strong> :</p>\n\n<ul>\n\t<li>每 <strong>分钟</strong> (60秒 块)<meta charset=\"UTF-8\" />&nbsp;<code>[10,69]</code>,&nbsp;<code>[70,129]</code>,&nbsp;<code>[130,189]</code>,&nbsp;<code>...</code>,&nbsp;<code>[9970,10000]</code></li>\n\t<li>每 <strong>小时</strong> (3600秒 块)<meta charset=\"UTF-8\" /><code>[10,3609]</code>,&nbsp;<code>[3610,7209]</code>,&nbsp;<code>[7210,10000]</code></li>\n\t<li>每 <strong>天</strong> (86400秒 块)<meta charset=\"UTF-8\" />&nbsp;<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&lt;integer&gt; getTweetCountsPerFrequency(String freq, String tweetName, int startTime, int endTime)</code>&nbsp;返回一个整数列表,表示给定时间 <code>[startTime, endTime]</code>&nbsp;(单位秒)和频率频率中,每个 <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>&nbsp;</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); //&nbsp;\"tweet3\"&nbsp;发布推文的时间分别是&nbsp;0,&nbsp;10&nbsp;和&nbsp;60 。\ntweetCounts.getTweetCountsPerFrequency(\"minute\", \"tweet3\", 0, 59); //&nbsp;返回&nbsp;[2]。统计频率是每分钟60 秒),因此只有一个有效时间间隔 [0,60&gt;&nbsp;-&nbsp;&gt;&nbsp;2&nbsp;条推文。\ntweetCounts.getTweetCountsPerFrequency(\"minute\", \"tweet3\", 0, 60); //&nbsp;返回&nbsp;[2,1]。统计频率是每分钟60 秒),因此有两个有效时间间隔&nbsp;<strong>1)</strong>&nbsp;[0,60&gt;&nbsp;-&nbsp;&gt;&nbsp;2&nbsp;条推文,和&nbsp;<strong>2)</strong>&nbsp;[60,61&gt;&nbsp;-&nbsp;&gt;&nbsp;1&nbsp;条推文。 \ntweetCounts.recordTweet(\"tweet3\", 120); // \"tweet3\"&nbsp;发布推文的时间分别是 0, 10, 60 和 120 。\ntweetCounts.getTweetCountsPerFrequency(\"hour\", \"tweet3\", 0, 210); //&nbsp;返回&nbsp;[4]。统计频率是每小时3600 秒),因此只有一个有效时间间隔 [0,211&gt;&nbsp;-&nbsp;&gt;&nbsp;4&nbsp;条推文。\n</pre>\n\n<p>&nbsp;</p>\n\n<p><strong>提示:</strong></p>\n\n<ul>\n\t<li><code>0 &lt;= time, startTime, endTime &lt;= 10<sup>9</sup></code></li>\n\t<li><code>0 &lt;= endTime - startTime &lt;= 10<sup>4</sup></code></li>\n\t<li><code>recordTweet</code>&nbsp;和&nbsp;<code>getTweetCountsPerFrequency</code>,最多有<meta charset=\"UTF-8\" />&nbsp;<code>10<sup>4</sup></code>&nbsp;次操作。</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,