mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-10-22 21:46:46 +08:00
update
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
"translatedContent": "<p>请你设计一个数据结构,它能求出给定子数组内一个给定值的 <strong>频率</strong> 。</p>\n\n<p>子数组中一个值的 <strong>频率</strong> 指的是这个子数组中这个值的出现次数。</p>\n\n<p>请你实现 <code>RangeFreqQuery</code> 类:</p>\n\n<ul>\n\t<li><code>RangeFreqQuery(int[] arr)</code> 用下标从 <strong>0</strong> 开始的整数数组 <code>arr</code> 构造一个类的实例。</li>\n\t<li><code>int query(int left, int right, int value)</code> 返回子数组 <code>arr[left...right]</code> 中 <code>value</code> 的 <strong>频率</strong> 。</li>\n</ul>\n\n<p>一个 <strong>子数组</strong> 指的是数组中一段连续的元素。<code>arr[left...right]</code> 指的是 <code>nums</code> 中包含下标 <code>left</code> 和 <code>right</code> <strong>在内</strong> 的中间一段连续元素。</p>\n\n<p> </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> </p>\n\n<p><strong>提示:</strong></p>\n\n<ul>\n\t<li><code>1 <= arr.length <= 10<sup>5</sup></code></li>\n\t<li><code>1 <= arr[i], value <= 10<sup>4</sup></code></li>\n\t<li><code>0 <= left <= right < arr.length</code></li>\n\t<li>调用 <code>query</code> 不超过 <code>10<sup>5</sup></code> 次。</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.",
|
||||
|
Reference in New Issue
Block a user