mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-10-24 14:28:56 +08:00
update
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
"translatedContent": "<p>给你两个整数数组 <code>persons</code> 和 <code>times</code> 。在选举中,第 <code>i</code> 张票是在时刻为 <code>times[i]</code> 时投给候选人 <code>persons[i]</code> 的。</p>\n\n<p>对于发生在时刻 <code>t</code> 的每个查询,需要找出在 <code>t</code> 时刻在选举中领先的候选人的编号。</p>\n\n<p>在 <code>t</code> 时刻投出的选票也将被计入我们的查询之中。在平局的情况下,最近获得投票的候选人将会获胜。</p>\n\n<p>实现 <code>TopVotedCandidate</code> 类:</p>\n\n<ul>\n\t<li><code>TopVotedCandidate(int[] persons, int[] times)</code> 使用 <code>persons</code> 和 <code>times</code> 数组初始化对象。</li>\n\t<li><code>int q(int t)</code> 根据前面描述的规则,返回在时刻 <code>t</code> 在选举中领先的候选人的编号。</li>\n</ul>\n \n\n<p><strong>示例:</strong></p>\n\n<pre>\n<strong>输入:</strong>\n[\"TopVotedCandidate\", \"q\", \"q\", \"q\", \"q\", \"q\", \"q\"]\n[[[0, 1, 1, 0, 0, 1, 0], [0, 5, 10, 15, 20, 25, 30]], [3], [12], [25], [15], [24], [8]]\n<strong>输出:</strong>\n[null, 0, 1, 1, 0, 0, 1]\n\n<strong>解释:</strong>\nTopVotedCandidate topVotedCandidate = new TopVotedCandidate([0, 1, 1, 0, 0, 1, 0], [0, 5, 10, 15, 20, 25, 30]);\ntopVotedCandidate.q(3); // 返回 0 ,在时刻 3 ,票数分布为 [0] ,编号为 0 的候选人领先。\ntopVotedCandidate.q(12); // 返回 1 ,在时刻 12 ,票数分布为 [0,1,1] ,编号为 1 的候选人领先。\ntopVotedCandidate.q(25); // 返回 1 ,在时刻 25 ,票数分布为 [0,1,1,0,0,1] ,编号为 1 的候选人领先。(在平局的情况下,1 是最近获得投票的候选人)。\ntopVotedCandidate.q(15); // 返回 0\ntopVotedCandidate.q(24); // 返回 0\ntopVotedCandidate.q(8); // 返回 1\n</pre>\n\n<p> </p>\n\n<p><strong>提示:</strong></p>\n\n<ul>\n\t<li><code>1 <= persons.length <= 5000</code></li>\n\t<li><code>times.length == persons.length</code></li>\n\t<li><code>0 <= persons[i] < persons.length</code></li>\n\t<li><code>0 <= times[i] <= 10<sup>9</sup></code></li>\n\t<li><code>times</code> 是一个严格递增的有序数组</li>\n\t<li><code>times[0] <= t <= 10<sup>9</sup></code></li>\n\t<li>每个测试用例最多调用 <code>10<sup>4</sup></code> 次 <code>q</code></li>\n</ul>\n",
|
||||
"isPaidOnly": false,
|
||||
"difficulty": "Medium",
|
||||
"likes": 138,
|
||||
"likes": 142,
|
||||
"dislikes": 0,
|
||||
"isLiked": null,
|
||||
"similarQuestions": "[]",
|
||||
@@ -155,7 +155,7 @@
|
||||
"__typename": "CodeSnippetNode"
|
||||
}
|
||||
],
|
||||
"stats": "{\"totalAccepted\": \"26.9K\", \"totalSubmission\": \"49.8K\", \"totalAcceptedRaw\": 26864, \"totalSubmissionRaw\": 49845, \"acRate\": \"53.9%\"}",
|
||||
"stats": "{\"totalAccepted\": \"27.3K\", \"totalSubmission\": \"50.8K\", \"totalAcceptedRaw\": 27330, \"totalSubmissionRaw\": 50769, \"acRate\": \"53.8%\"}",
|
||||
"hints": [],
|
||||
"solution": null,
|
||||
"status": null,
|
||||
|
||||
Reference in New Issue
Block a user