1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-09-09 17:31:41 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee

移除零宽空格

This commit is contained in:
2025-05-25 15:06:02 +08:00
parent 59597532bc
commit 3070bed723
272 changed files with 1031 additions and 749 deletions

View File

@@ -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>&nbsp;</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>&nbsp;group: [2] has power = 2<sup>2</sup>&nbsp;* 2 = 8.\n2<sup>nd</sup>&nbsp;group: [1] has power = 1<sup>2</sup> * 1 = 1. \n3<sup>rd</sup>&nbsp;group: [4] has power = 4<sup>2</sup> * 4 = 64. \n4<sup>th</sup>&nbsp;group: [2,1] has power = 2<sup>2</sup> * 1 = 4. \n5<sup>th</sup>&nbsp;group: [2,4] has power = 4<sup>2</sup> * 2 = 32. \n6<sup>th</sup>&nbsp;group: [1,4] has power = 4<sup>2</sup> * 1 = 16. \n7<sup>th</sup>&nbsp;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>&nbsp;</p>\n<p><strong>Constraints:</strong></p>\n\n<ul>\n\t<li><code>1 &lt;= nums.length &lt;= 10<sup>5</sup></code></li>\n\t<li><code>1 &lt;= nums[i] &lt;= 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>&nbsp;</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>&nbsp;group: [2] has power = 2<sup>2</sup>&nbsp;* 2 = 8.\n2<sup>nd</sup>&nbsp;group: [1] has power = 1<sup>2</sup> * 1 = 1. \n3<sup>rd</sup>&nbsp;group: [4] has power = 4<sup>2</sup> * 4 = 64. \n4<sup>th</sup>&nbsp;group: [2,1] has power = 2<sup>2</sup> * 1 = 4. \n5<sup>th</sup>&nbsp;group: [2,4] has power = 4<sup>2</sup> * 2 = 32. \n6<sup>th</sup>&nbsp;group: [1,4] has power = 4<sup>2</sup> * 1 = 16. \n7<sup>th</sup>&nbsp;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>&nbsp;</p>\n<p><strong>Constraints:</strong></p>\n\n<ul>\n\t<li><code>1 &lt;= nums.length &lt;= 10<sup>5</sup></code></li>\n\t<li><code>1 &lt;= nums[i] &lt;= 10<sup>9</sup></code></li>\n</ul>\n",
"translatedTitle": "英雄的力量",
"translatedContent": "<p>给你一个下标从 <strong>0</strong>&nbsp;开始的整数数组&nbsp;<code>nums</code>&nbsp;,它表示英雄的能力值。如果我们选出一部分英雄,这组英雄的 <strong>力量</strong>&nbsp;定义为:</p>\n\n<ul>\n\t<li><code>i<sub>0</sub></code>&nbsp;<code>i<sub>1</sub></code>&nbsp;<span style=\"\">... </span><code><span style=\"\">i<sub>k</sub></span></code><span style=\"\">&nbsp;</span>表示这组英雄在数组中的下标。那么这组英雄的力量为&nbsp;<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> 之和。由于答案可能非常大,请你将结果对&nbsp;<code>10<sup>9 </sup>+ 7</code>&nbsp;<strong>取余。</strong></p>\n\n<p>&nbsp;</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&nbsp;组:[2] 的力量为 2<sup>2</sup>&nbsp;* 2 = 8 。\n第 2&nbsp;组:[1] 的力量为 1<sup>2</sup> * 1 = 1 。\n第 3&nbsp;组:[4] 的力量为 4<sup>2</sup> * 4 = 64 。\n第 4&nbsp;组:[2,1] 的力量为 2<sup>2</sup> * 1 = 4 。\n第 5 组:[2,4] 的力量为 4<sup>2</sup> * 2 = 32 。\n第 6&nbsp;组:[1,4] 的力量为 4<sup>2</sup> * 1 = 16 。\n第 7&nbsp;组:[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>&nbsp;</p>\n\n<p><strong>提示:</strong></p>\n\n<ul>\n\t<li><code>1 &lt;= nums.length &lt;= 10<sup>5</sup></code></li>\n\t<li><code>1 &lt;= nums[i] &lt;= 10<sup>9</sup></code></li>\n</ul>\n",
"translatedContent": "<p>给你一个下标从 <strong>0</strong>&nbsp;开始的整数数组&nbsp;<code>nums</code>&nbsp;,它表示英雄的能力值。如果我们选出一部分英雄,这组英雄的 <strong>力量</strong>&nbsp;定义为:</p>\n\n<ul>\n\t<li><code>i<sub>0</sub></code>&nbsp;<code>i<sub>1</sub></code>&nbsp;<span style=\"\">... </span><code><span style=\"\">i<sub>k</sub></span></code><span style=\"\">&nbsp;</span>表示这组英雄在数组中的下标。那么这组英雄的力量为&nbsp;<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> 之和。由于答案可能非常大,请你将结果对&nbsp;<code>10<sup>9 </sup>+ 7</code>&nbsp;<strong>取余。</strong></p>\n\n<p>&nbsp;</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&nbsp;组:[2] 的力量为 2<sup>2</sup>&nbsp;* 2 = 8 。\n第 2&nbsp;组:[1] 的力量为 1<sup>2</sup> * 1 = 1 。\n第 3&nbsp;组:[4] 的力量为 4<sup>2</sup> * 4 = 64 。\n第 4&nbsp;组:[2,1] 的力量为 2<sup>2</sup> * 1 = 4 。\n第 5 组:[2,4] 的力量为 4<sup>2</sup> * 2 = 32 。\n第 6&nbsp;组:[1,4] 的力量为 4<sup>2</sup> * 1 = 16 。\n第 7&nbsp;组:[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>&nbsp;</p>\n\n<p><strong>提示:</strong></p>\n\n<ul>\n\t<li><code>1 &lt;= nums.length &lt;= 10<sup>5</sup></code></li>\n\t<li><code>1 &lt;= nums[i] &lt;= 10<sup>9</sup></code></li>\n</ul>\n",
"isPaidOnly": false,
"difficulty": "Hard",
"likes": 156,