1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-09-09 01:11:42 +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,7 +7,7 @@
"boundTopicId": 2773142,
"title": "Taking Maximum Energy From the Mystic Dungeon",
"titleSlug": "taking-maximum-energy-from-the-mystic-dungeon",
"content": "<p>In a mystic dungeon, <code>n</code> magicians are standing in a line. Each magician has an attribute that gives you energy. Some magicians can give you negative energy, which means taking energy from you.</p>\n\n<p>You have been cursed in such a way that after absorbing energy from magician <code>i</code>, you will be instantly transported to magician <code>(i + k)</code>. This process will be repeated until you reach the magician where <code>(i + k)</code> does not exist.</p>\n\n<p>In other words, you will choose a starting point and then teleport with <code>k</code> jumps until you reach the end of the magicians&#39; sequence, <strong>absorbing all the energy</strong> during the journey.</p>\n\n<p>You are given an array <code>energy</code> and an integer <code>k</code>. Return the <strong>maximum</strong> possible energy you can gain.</p>\n\n<p>&nbsp;</p>\n<p><strong class=\"example\">Example 1:</strong></p>\n\n<div class=\"example-block\" style=\"\n border-color: var(--border-tertiary);\n border-left-width: 2px;\n color: var(--text-secondary);\n font-size: .875rem;\n margin-bottom: 1rem;\n margin-top: 1rem;\n overflow: visible;\n padding-left: 1rem;\n\">\n<p><strong>Input:</strong> <span class=\"example-io\" style=\"\n font-family: Menlo,sans-serif;\n font-size: 0.85rem;\n\"> energy = [5,2,-10,-5,1], k = 3</span></p>\n\n<p><strong>Output:</strong><span class=\"example-io\" style=\"\n font-family: Menlo,sans-serif;\n font-size: 0.85rem;\n\"> 3</span></p>\n\n<p><strong>Explanation:</strong> We can gain a total energy of 3 by starting from magician 1 absorbing 2 + 1 = 3.</p>\n</div>\n\n<p><strong class=\"example\">Example 2:</strong></p>\n\n<div class=\"example-block\" style=\"\n border-color: var(--border-tertiary);\n border-left-width: 2px;\n color: var(--text-secondary);\n font-size: .875rem;\n margin-bottom: 1rem;\n margin-top: 1rem;\n overflow: visible;\n padding-left: 1rem;\n\">\n<p><strong>Input:</strong><span class=\"example-io\" style=\"\n font-family: Menlo,sans-serif;\n font-size: 0.85rem;\n\"> energy = [-2,-3,-1], k = 2</span></p>\n\n<p><strong>Output:</strong><span class=\"example-io\" style=\"\n font-family: Menlo,sans-serif;\n font-size: 0.85rem;\n\"> -1</span></p>\n\n<p><strong>Explanation:</strong> We can gain a total energy of -1 by starting from magician 2.</p>\n</div>\n\n<p>&nbsp;</p>\n<p><strong>Constraints:</strong></p>\n\n<ul>\n\t<li><code>1 &lt;= energy.length &lt;= 10<sup>5</sup></code></li>\n\t<li><code>-1000 &lt;= energy[i] &lt;= 1000</code></li>\n\t<li><code>1 &lt;= k &lt;= energy.length - 1</code></li>\n</ul>\n\n<p>&nbsp;</p>\n",
"content": "<p>In a mystic dungeon, <code>n</code> magicians are standing in a line. Each magician has an attribute that gives you energy. Some magicians can give you negative energy, which means taking energy from you.</p>\n\n<p>You have been cursed in such a way that after absorbing energy from magician <code>i</code>, you will be instantly transported to magician <code>(i + k)</code>. This process will be repeated until you reach the magician where <code>(i + k)</code> does not exist.</p>\n\n<p>In other words, you will choose a starting point and then teleport with <code>k</code> jumps until you reach the end of the magicians&#39; sequence, <strong>absorbing all the energy</strong> during the journey.</p>\n\n<p>You are given an array <code>energy</code> and an integer <code>k</code>. Return the <strong>maximum</strong> possible energy you can gain.</p>\n\n<p>&nbsp;</p>\n<p><strong class=\"example\">Example 1:</strong></p>\n\n<div class=\"example-block\" style=\"\n border-color: var(--border-tertiary);\n border-left-width: 2px;\n color: var(--text-secondary);\n font-size: .875rem;\n margin-bottom: 1rem;\n margin-top: 1rem;\n overflow: visible;\n padding-left: 1rem;\n\">\n<p><strong>Input:</strong> <span class=\"example-io\" style=\"\n font-family: Menlo,sans-serif;\n font-size: 0.85rem;\n\"> energy = [5,2,-10,-5,1], k = 3</span></p>\n\n<p><strong>Output:</strong><span class=\"example-io\" style=\"\n font-family: Menlo,sans-serif;\n font-size: 0.85rem;\n\"> 3</span></p>\n\n<p><strong>Explanation:</strong> We can gain a total energy of 3 by starting from magician 1 absorbing 2 + 1 = 3.</p>\n</div>\n\n<p><strong class=\"example\">Example 2:</strong></p>\n\n<div class=\"example-block\" style=\"\n border-color: var(--border-tertiary);\n border-left-width: 2px;\n color: var(--text-secondary);\n font-size: .875rem;\n margin-bottom: 1rem;\n margin-top: 1rem;\n overflow: visible;\n padding-left: 1rem;\n\">\n<p><strong>Input:</strong><span class=\"example-io\" style=\"\n font-family: Menlo,sans-serif;\n font-size: 0.85rem;\n\"> energy = [-2,-3,-1], k = 2</span></p>\n\n<p><strong>Output:</strong><span class=\"example-io\" style=\"\n font-family: Menlo,sans-serif;\n font-size: 0.85rem;\n\"> -1</span></p>\n\n<p><strong>Explanation:</strong> We can gain a total energy of -1 by starting from magician 2.</p>\n</div>\n\n<p>&nbsp;</p>\n<p><strong>Constraints:</strong></p>\n\n<ul>\n\t<li><code>1 &lt;= energy.length &lt;= 10<sup>5</sup></code></li>\n\t<li><code>-1000 &lt;= energy[i] &lt;= 1000</code></li>\n\t<li><code>1 &lt;= k &lt;= energy.length - 1</code></li>\n</ul>\n\n<p>&nbsp;</p>\n",
"translatedTitle": "从魔法师身上吸取的最大能量",
"translatedContent": "<p>在神秘的地牢中,<code>n</code> 个魔法师站成一排。每个魔法师都拥有一个属性,这个属性可以给你提供能量。有些魔法师可能会给你负能量,即从你身上吸取能量。</p>\n\n<p>你被施加了一种诅咒,当你从魔法师 <code>i</code> 处吸收能量后,你将被立即传送到魔法师 <code>(i + k)</code> 处。这一过程将重复进行,直到你到达一个不存在 <code>(i + k)</code> 的魔法师为止。</p>\n\n<p>换句话说,你将选择一个起点,然后以 <code>k</code> 为间隔跳跃,直到到达魔法师序列的末端,<strong>在过程中吸收所有的能量</strong>。</p>\n\n<p>给定一个数组 <code>energy</code> 和一个整数<code>k</code>,返回你能获得的<strong> 最大 </strong>能量。</p>\n\n<p>&nbsp;</p>\n\n<p><strong class=\"example\">示例 1</strong></p>\n\n<div class=\"example-block\" style=\"\n border-color: var(--border-tertiary);\n border-left-width: 2px;\n color: var(--text-secondary);\n font-size: .875rem;\n margin-bottom: 1rem;\n margin-top: 1rem;\n overflow: visible;\n padding-left: 1rem;\n\">\n<p><strong>输入:</strong><span class=\"example-io\" style=\"\n font-family: Menlo,sans-serif;\n font-size: 0.85rem;\n\"> energy = [5,2,-10,-5,1], k = 3</span></p>\n\n<p><strong>输出:</strong><span class=\"example-io\" style=\"\n font-family: Menlo,sans-serif;\n font-size: 0.85rem;\n\"> 3</span></p>\n\n<p><strong>解释:</strong>可以从魔法师 1 开始,吸收能量 2 + 1 = 3。</p>\n</div>\n\n<p><strong class=\"example\">示例 2</strong></p>\n\n<div class=\"example-block\" style=\"\n border-color: var(--border-tertiary);\n border-left-width: 2px;\n color: var(--text-secondary);\n font-size: .875rem;\n margin-bottom: 1rem;\n margin-top: 1rem;\n overflow: visible;\n padding-left: 1rem;\n\">\n<p><strong>输入:</strong><span class=\"example-io\" style=\"\n font-family: Menlo,sans-serif;\n font-size: 0.85rem;\n\"> energy = [-2,-3,-1], k = 2</span></p>\n\n<p><strong>输出:</strong><span class=\"example-io\" style=\"\n font-family: Menlo,sans-serif;\n font-size: 0.85rem;\n\"> -1</span></p>\n\n<p><strong>解释:</strong>可以从魔法师 2 开始,吸收能量 -1。</p>\n</div>\n\n<p>&nbsp;</p>\n\n<p><strong>提示:</strong></p>\n\n<ul>\n\t<li><code>1 &lt;= energy.length &lt;= 10<sup>5</sup></code></li>\n\t<li><code>-1000 &lt;= energy[i] &lt;= 1000</code></li>\n\t<li><code>1 &lt;= k &lt;= energy.length - 1</code></li>\n</ul>\n\n<p>&nbsp;</p>\n",
"isPaidOnly": false,