1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-09-05 07:21:40 +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;<code>RecentCounter</code>&nbsp;类来计算特定时间范围内最近的请求。</p>\n\n<p>请你实现 <code>RecentCounter</code> 类:</p>\n\n<ul>\n\t<li><code>RecentCounter()</code> 初始化计数器,请求数为 0 。</li>\n\t<li><code>int ping(int t)</code> 在时间 <code>t</code> 添加一个新请求,其中 <code>t</code> 表示以毫秒为单位的某个时间,并返回过去 <code>3000</code> 毫秒内发生的所有请求数(包括新请求)。确切地说,返回在 <code>[t-3000, t]</code> 内发生的请求数。</li>\n</ul>\n\n<p><strong>保证</strong> 每次对 <code>ping</code> 的调用都使用比之前更大的 <code>t</code> 值。</p>\n\n<p>&nbsp;</p>\n\n<p><strong>示例 1</strong></p>\n\n<pre>\n<strong>输入:</strong>\n[\"RecentCounter\", \"ping\", \"ping\", \"ping\", \"ping\"]\n[[], [1], [100], [3001], [3002]]\n<strong>输出:</strong>\n[null, 1, 2, 3, 3]\n\n<strong>解释:</strong>\nRecentCounter recentCounter = new RecentCounter();\nrecentCounter.ping(1); // requests = [<strong>1</strong>],范围是 [-2999,1],返回 1\nrecentCounter.ping(100); // requests = [<strong>1</strong>, <strong>100</strong>],范围是 [-2900,100],返回 2\nrecentCounter.ping(3001); // requests = [<strong>1</strong>, <strong>100</strong>, <strong>3001</strong>],范围是 [1,3001],返回 3\nrecentCounter.ping(3002); // requests = [1, <strong>100</strong>, <strong>3001</strong>, <strong>3002</strong>],范围是 [2,3002],返回 3\n</pre>\n\n<p>&nbsp;</p>\n\n<p><strong>提示:</strong></p>\n\n<ul>\n\t<li><code>1 &lt;= t &lt;= 10<sup>9</sup></code></li>\n\t<li>保证每次对 <code>ping</code> 调用所使用的 <code>t</code> 值都 <strong>严格递增</strong></li>\n\t<li>至多调用 <code>ping</code> 方法 <code>10<sup>4</sup></code> 次</li>\n</ul>\n",
"isPaidOnly": false,
"difficulty": "Easy",
"likes": 118,
"likes": 120,
"dislikes": 0,
"isLiked": null,
"similarQuestions": "[]",
@@ -149,7 +149,7 @@
"__typename": "CodeSnippetNode"
}
],
"stats": "{\"totalAccepted\": \"44.1K\", \"totalSubmission\": \"60.4K\", \"totalAcceptedRaw\": 44081, \"totalSubmissionRaw\": 60435, \"acRate\": \"72.9%\"}",
"stats": "{\"totalAccepted\": \"45.5K\", \"totalSubmission\": \"62.4K\", \"totalAcceptedRaw\": 45540, \"totalSubmissionRaw\": 62403, \"acRate\": \"73.0%\"}",
"hints": [],
"solution": null,
"status": null,