mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-09-05 23:41:41 +08:00
存量题库数据更新
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
"translatedContent": "<p>给你一个下标从 <strong>0</strong> 开始的整数数组 <code>nums</code> 。</p>\n\n<p>定义 <code>nums</code> 一个子数组的 <strong>不同计数</strong> 值如下:</p>\n\n<ul>\n\t<li>令 <code>nums[i..j]</code> 表示 <code>nums</code> 中所有下标在 <code>i</code> 到 <code>j</code> 范围内的元素构成的子数组(满足 <code>0 <= i <= j < nums.length</code> ),那么我们称子数组 <code>nums[i..j]</code> 中不同值的数目为 <code>nums[i..j]</code> 的不同计数。</li>\n</ul>\n\n<p>请你返回 <code>nums</code> 中所有子数组的 <strong>不同计数</strong> 的 <strong>平方</strong> 和。</p>\n\n<p>由于答案可能会很大,请你将它对 <code>10<sup>9</sup> + 7</code> <strong>取余</strong> 后返回。</p>\n\n<p>子数组指的是一个数组里面一段连续 <strong>非空</strong> 的元素序列。</p>\n\n<p> </p>\n\n<p><strong class=\"example\">示例 1:</strong></p>\n\n<pre>\n<b>输入:</b>nums = [1,2,1]\n<b>输出:</b>15\n<b>解释:</b>六个子数组分别为:\n[1]: 1 个互不相同的元素。\n[2]: 1 个互不相同的元素。\n[1]: 1 个互不相同的元素。\n[1,2]: 2 个互不相同的元素。\n[2,1]: 2 个互不相同的元素。\n[1,2,1]: 2 个互不相同的元素。\n所有不同计数的平方和为 1<sup>2</sup> + 1<sup>2</sup> + 1<sup>2</sup> + 2<sup>2</sup> + 2<sup>2</sup> + 2<sup>2</sup> = 15 。\n</pre>\n\n<p><strong class=\"example\">示例 2:</strong></p>\n\n<pre>\n<b>输入:</b>nums = [2,2]\n<b>输出:3</b>\n<strong>解释:</strong>三个子数组分别为:\n[2]: 1 个互不相同的元素。\n[2]: 1 个互不相同的元素。\n[2,2]: 1 个互不相同的元素。\n所有不同计数的平方和为 1<sup>2</sup> + 1<sup>2</sup> + 1<sup>2</sup> = 3 。\n</pre>\n\n<p> </p>\n\n<p><strong>提示:</strong></p>\n\n<ul>\n\t<li><code>1 <= nums.length <= 10<sup>5</sup></code></li>\n\t<li><code>1 <= nums[i] <= 10<sup>5</sup></code></li>\n</ul>\n",
|
||||
"isPaidOnly": false,
|
||||
"difficulty": "Hard",
|
||||
"likes": 9,
|
||||
"likes": 15,
|
||||
"dislikes": 0,
|
||||
"isLiked": null,
|
||||
"similarQuestions": "[]",
|
||||
@@ -161,7 +161,7 @@
|
||||
"__typename": "CodeSnippetNode"
|
||||
}
|
||||
],
|
||||
"stats": "{\"totalAccepted\": \"1.2K\", \"totalSubmission\": \"3.6K\", \"totalAcceptedRaw\": 1248, \"totalSubmissionRaw\": 3553, \"acRate\": \"35.1%\"}",
|
||||
"stats": "{\"totalAccepted\": \"1.6K\", \"totalSubmission\": \"4.2K\", \"totalAcceptedRaw\": 1572, \"totalSubmissionRaw\": 4209, \"acRate\": \"37.3%\"}",
|
||||
"hints": [
|
||||
"Consider the sum of the count of distinct values of subarrays ending with index <code>i</code>, let’s call it <code>sum</code>. Now if you need the sum of all subarrays ending with index <code>i + 1</code> think how it can be related to <code>sum</code> and what extra will be needed to add to this.",
|
||||
"You can find that extra sum using the segment tree."
|
||||
|
Reference in New Issue
Block a user