mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-09-09 17:31:41 +08:00
移除零宽空格
This commit is contained in:
@@ -7,9 +7,9 @@
|
||||
"boundTopicId": 2266665,
|
||||
"title": "Power of Heroes",
|
||||
"titleSlug": "power-of-heroes",
|
||||
"content": "<p>You are given a <strong>0-indexed</strong> integer array <code>nums</code> representing the strength of some heroes. The<b> power</b> of a group of heroes is defined as follows:</p>\n\n<ul>\n\t<li>Let <code>i<sub>0</sub></code>, <code>i<sub>1</sub></code>, ... ,<code>i<sub>k</sub></code> be the indices of the heroes in a group. Then, the power of this group is <code>max(nums[i<sub>0</sub>], nums[i<sub>1</sub>], ... ,nums[i<sub>k</sub>])<sup>2</sup> * min(nums[i<sub>0</sub>], nums[i<sub>1</sub>], ... ,nums[i<sub>k</sub>])</code>.</li>\n</ul>\n\n<p>Return <em>the sum of the <strong>power</strong> of all <strong>non-empty</strong> groups of heroes possible.</em> Since the sum could be very large, return it <strong>modulo</strong> <code>10<sup>9 </sup>+ 7</code>.</p>\n\n<p> </p>\n<p><strong class=\"example\">Example 1:</strong></p>\n\n<pre>\n<strong>Input:</strong> nums = [2,1,4]\n<strong>Output:</strong> 141\n<strong>Explanation:</strong> \n1<sup>st</sup> group: [2] has power = 2<sup>2</sup> * 2 = 8.\n2<sup>nd</sup> group: [1] has power = 1<sup>2</sup> * 1 = 1. \n3<sup>rd</sup> group: [4] has power = 4<sup>2</sup> * 4 = 64. \n4<sup>th</sup> group: [2,1] has power = 2<sup>2</sup> * 1 = 4. \n5<sup>th</sup> group: [2,4] has power = 4<sup>2</sup> * 2 = 32. \n6<sup>th</sup> group: [1,4] has power = 4<sup>2</sup> * 1 = 16. \n7<sup>th</sup> group: [2,1,4] has power = 4<sup>2</sup> * 1 = 16. \nThe sum of powers of all groups is 8 + 1 + 64 + 4 + 32 + 16 + 16 = 141.\n\n</pre>\n\n<p><strong class=\"example\">Example 2:</strong></p>\n\n<pre>\n<strong>Input:</strong> nums = [1,1,1]\n<strong>Output:</strong> 7\n<strong>Explanation:</strong> A total of 7 groups are possible, and the power of each group will be 1. Therefore, the sum of the powers of all groups is 7.\n</pre>\n\n<p> </p>\n<p><strong>Constraints:</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>9</sup></code></li>\n</ul>\n",
|
||||
"content": "<p>You are given a <strong>0-indexed</strong> integer array <code>nums</code> representing the strength of some heroes. The<b> power</b> of a group of heroes is defined as follows:</p>\n\n<ul>\n\t<li>Let <code>i<sub>0</sub></code>, <code>i<sub>1</sub></code>, ... ,<code>i<sub>k</sub></code> be the indices of the heroes in a group. Then, the power of this group is <code>max(nums[i<sub>0</sub>], nums[i<sub>1</sub>], ... ,nums[i<sub>k</sub>])<sup>2</sup> * min(nums[i<sub>0</sub>], nums[i<sub>1</sub>], ... ,nums[i<sub>k</sub>])</code>.</li>\n</ul>\n\n<p>Return <em>the sum of the <strong>power</strong> of all <strong>non-empty</strong> groups of heroes possible.</em> Since the sum could be very large, return it <strong>modulo</strong> <code>10<sup>9 </sup>+ 7</code>.</p>\n\n<p> </p>\n<p><strong class=\"example\">Example 1:</strong></p>\n\n<pre>\n<strong>Input:</strong> nums = [2,1,4]\n<strong>Output:</strong> 141\n<strong>Explanation:</strong> \n1<sup>st</sup> group: [2] has power = 2<sup>2</sup> * 2 = 8.\n2<sup>nd</sup> group: [1] has power = 1<sup>2</sup> * 1 = 1. \n3<sup>rd</sup> group: [4] has power = 4<sup>2</sup> * 4 = 64. \n4<sup>th</sup> group: [2,1] has power = 2<sup>2</sup> * 1 = 4. \n5<sup>th</sup> group: [2,4] has power = 4<sup>2</sup> * 2 = 32. \n6<sup>th</sup> group: [1,4] has power = 4<sup>2</sup> * 1 = 16. \n7<sup>th</sup> group: [2,1,4] has power = 4<sup>2</sup> * 1 = 16. \nThe sum of powers of all groups is 8 + 1 + 64 + 4 + 32 + 16 + 16 = 141.\n\n</pre>\n\n<p><strong class=\"example\">Example 2:</strong></p>\n\n<pre>\n<strong>Input:</strong> nums = [1,1,1]\n<strong>Output:</strong> 7\n<strong>Explanation:</strong> A total of 7 groups are possible, and the power of each group will be 1. Therefore, the sum of the powers of all groups is 7.\n</pre>\n\n<p> </p>\n<p><strong>Constraints:</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>9</sup></code></li>\n</ul>\n",
|
||||
"translatedTitle": "英雄的力量",
|
||||
"translatedContent": "<p>给你一个下标从 <strong>0</strong> 开始的整数数组 <code>nums</code> ,它表示英雄的能力值。如果我们选出一部分英雄,这组英雄的 <strong>力量</strong> 定义为:</p>\n\n<ul>\n\t<li><code>i<sub>0</sub></code> ,<code>i<sub>1</sub></code> ,<span style=\"\">... </span><code><span style=\"\">i<sub>k</sub></span></code><span style=\"\"> </span>表示这组英雄在数组中的下标。那么这组英雄的力量为 <code><font face=\"monospace\">max(nums[</font>i<sub>0</sub><font face=\"monospace\">],nums[</font>i<sub>1</sub><font face=\"monospace\">] ... nums[</font><span style=\"font-size:10.8333px\">i<sub>k</sub></span><font face=\"monospace\">])<sup>2</sup> * min(nums[</font>i<sub>0</sub><font face=\"monospace\">],nums[</font>i<sub>1</sub><font face=\"monospace\">] ... nums[</font><span style=\"font-size:10.8333px\">i<sub>k</sub></span><font face=\"monospace\">])</font></code> 。</li>\n</ul>\n\n<p>请你返回所有可能的 <strong>非空</strong> 英雄组的 <strong>力量</strong> 之和。由于答案可能非常大,请你将结果对 <code>10<sup>9 </sup>+ 7</code> <strong>取余。</strong></p>\n\n<p> </p>\n\n<p><strong>示例 1:</strong></p>\n\n<pre>\n<b>输入:</b>nums = [2,1,4]\n<b>输出:</b>141\n<b>解释:</b>\n第 1 组:[2] 的力量为 2<sup>2</sup> * 2 = 8 。\n第 2 组:[1] 的力量为 1<sup>2</sup> * 1 = 1 。\n第 3 组:[4] 的力量为 4<sup>2</sup> * 4 = 64 。\n第 4 组:[2,1] 的力量为 2<sup>2</sup> * 1 = 4 。\n第 5 组:[2,4] 的力量为 4<sup>2</sup> * 2 = 32 。\n第 6 组:[1,4] 的力量为 4<sup>2</sup> * 1 = 16 。\n第 7 组:[2,1,4] 的力量为 4<sup>2</sup> * 1 = 16 。\n所有英雄组的力量之和为 8 + 1 + 64 + 4 + 32 + 16 + 16 = 141 。\n</pre>\n\n<p><strong>示例 2:</strong></p>\n\n<pre>\n<b>输入:</b>nums = [1,1,1]\n<b>输出:</b>7\n<b>解释:</b>总共有 7 个英雄组,每一组的力量都是 1 。所以所有英雄组的力量之和为 7 。\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>9</sup></code></li>\n</ul>\n",
|
||||
"translatedContent": "<p>给你一个下标从 <strong>0</strong> 开始的整数数组 <code>nums</code> ,它表示英雄的能力值。如果我们选出一部分英雄,这组英雄的 <strong>力量</strong> 定义为:</p>\n\n<ul>\n\t<li><code>i<sub>0</sub></code> ,<code>i<sub>1</sub></code> ,<span style=\"\">... </span><code><span style=\"\">i<sub>k</sub></span></code><span style=\"\"> </span>表示这组英雄在数组中的下标。那么这组英雄的力量为 <code><font face=\"monospace\">max(nums[</font>i<sub>0</sub><font face=\"monospace\">],nums[</font>i<sub>1</sub><font face=\"monospace\">] ... nums[</font><span style=\"font-size:10.8333px\">i<sub>k</sub></span><font face=\"monospace\">])<sup>2</sup> * min(nums[</font>i<sub>0</sub><font face=\"monospace\">],nums[</font>i<sub>1</sub><font face=\"monospace\">] ... nums[</font><span style=\"font-size:10.8333px\">i<sub>k</sub></span><font face=\"monospace\">])</font></code> 。</li>\n</ul>\n\n<p>请你返回所有可能的 <strong>非空</strong> 英雄组的 <strong>力量</strong> 之和。由于答案可能非常大,请你将结果对 <code>10<sup>9 </sup>+ 7</code> <strong>取余。</strong></p>\n\n<p> </p>\n\n<p><strong>示例 1:</strong></p>\n\n<pre>\n<b>输入:</b>nums = [2,1,4]\n<b>输出:</b>141\n<b>解释:</b>\n第 1 组:[2] 的力量为 2<sup>2</sup> * 2 = 8 。\n第 2 组:[1] 的力量为 1<sup>2</sup> * 1 = 1 。\n第 3 组:[4] 的力量为 4<sup>2</sup> * 4 = 64 。\n第 4 组:[2,1] 的力量为 2<sup>2</sup> * 1 = 4 。\n第 5 组:[2,4] 的力量为 4<sup>2</sup> * 2 = 32 。\n第 6 组:[1,4] 的力量为 4<sup>2</sup> * 1 = 16 。\n第 7 组:[2,1,4] 的力量为 4<sup>2</sup> * 1 = 16 。\n所有英雄组的力量之和为 8 + 1 + 64 + 4 + 32 + 16 + 16 = 141 。\n</pre>\n\n<p><strong>示例 2:</strong></p>\n\n<pre>\n<b>输入:</b>nums = [1,1,1]\n<b>输出:</b>7\n<b>解释:</b>总共有 7 个英雄组,每一组的力量都是 1 。所以所有英雄组的力量之和为 7 。\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>9</sup></code></li>\n</ul>\n",
|
||||
"isPaidOnly": false,
|
||||
"difficulty": "Hard",
|
||||
"likes": 156,
|
||||
|
Reference in New Issue
Block a user