1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-10-22 21:46:46 +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>请你设计一个数据结构,它能求出给定子数组内一个给定值的 <strong>频率</strong>&nbsp;。</p>\n\n<p>子数组中一个值的 <strong>频率</strong>&nbsp;指的是这个子数组中这个值的出现次数。</p>\n\n<p>请你实现&nbsp;<code>RangeFreqQuery</code>&nbsp;类:</p>\n\n<ul>\n\t<li><code>RangeFreqQuery(int[] arr)</code>&nbsp;用下标从 <strong>0</strong>&nbsp;开始的整数数组&nbsp;<code>arr</code>&nbsp;构造一个类的实例。</li>\n\t<li><code>int query(int left, int right, int value)</code>&nbsp;返回子数组&nbsp;<code>arr[left...right]</code>&nbsp;中&nbsp;<code>value</code>&nbsp;的&nbsp;<strong>频率</strong>&nbsp;。</li>\n</ul>\n\n<p>一个 <strong>子数组</strong> 指的是数组中一段连续的元素。<code>arr[left...right]</code>&nbsp;指的是 <code>nums</code>&nbsp;中包含下标 <code>left</code>&nbsp;和 <code>right</code>&nbsp;<strong>在内</strong>&nbsp;的中间一段连续元素。</p>\n\n<p>&nbsp;</p>\n\n<p><strong>示例 1</strong></p>\n\n<pre><strong>输入:</strong>\n[\"RangeFreqQuery\", \"query\", \"query\"]\n[[[12, 33, 4, 56, 22, 2, 34, 33, 22, 12, 34, 56]], [1, 2, 4], [0, 11, 33]]\n<strong>输出:</strong>\n[null, 1, 2]\n\n<strong>解释:</strong>\nRangeFreqQuery rangeFreqQuery = new RangeFreqQuery([12, 33, 4, 56, 22, 2, 34, 33, 22, 12, 34, 56]);\nrangeFreqQuery.query(1, 2, 4); // 返回 1 。4 在子数组 [33, 4] 中出现 1 次。\nrangeFreqQuery.query(0, 11, 33); // 返回 2 。33 在整个子数组中出现 2 次。\n</pre>\n\n<p>&nbsp;</p>\n\n<p><strong>提示:</strong></p>\n\n<ul>\n\t<li><code>1 &lt;= arr.length &lt;= 10<sup>5</sup></code></li>\n\t<li><code>1 &lt;= arr[i], value &lt;= 10<sup>4</sup></code></li>\n\t<li><code>0 &lt;= left &lt;= right &lt; arr.length</code></li>\n\t<li>调用&nbsp;<code>query</code>&nbsp;不超过&nbsp;<code>10<sup>5</sup></code>&nbsp;次。</li>\n</ul>\n",
"isPaidOnly": false,
"difficulty": "Medium",
"likes": 34,
"likes": 35,
"dislikes": 0,
"isLiked": null,
"similarQuestions": "[]",
@@ -161,7 +161,7 @@
"__typename": "CodeSnippetNode"
}
],
"stats": "{\"totalAccepted\": \"6K\", \"totalSubmission\": \"21K\", \"totalAcceptedRaw\": 5960, \"totalSubmissionRaw\": 20968, \"acRate\": \"28.4%\"}",
"stats": "{\"totalAccepted\": \"6.3K\", \"totalSubmission\": \"21.8K\", \"totalAcceptedRaw\": 6298, \"totalSubmissionRaw\": 21762, \"acRate\": \"28.9%\"}",
"hints": [
"The queries must be answered efficiently to avoid time limit exceeded verdict.",
"Store the elements of the array in a data structure that helps answering the queries efficiently.",