mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-10-25 23:08:57 +08:00
update
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
"translatedContent": "<p>给你两个长度分别 <code>n</code> 和 <code>m</code> 的整数数组 <code>nums</code> 和 <code>multipliers</code><strong> </strong>,其中 <code>n >= m</code> ,数组下标 <strong>从 1 开始</strong> 计数。</p>\n\n<p>初始时,你的分数为 <code>0</code> 。你需要执行恰好 <code>m</code> 步操作。在第 <code>i</code> 步操作(<strong>从 1 开始</strong> 计数)中,需要:</p>\n\n<ul>\n\t<li>选择数组 <code>nums</code> <strong>开头处或者末尾处</strong> 的整数 <code>x</code> 。</li>\n\t<li>你获得 <code>multipliers[i] * x</code> 分,并累加到你的分数中。</li>\n\t<li>将 <code>x</code> 从数组 <code>nums</code> 中移除。</li>\n</ul>\n\n<p>在执行<em> </em><code>m</code> 步操作后,返回 <strong>最大</strong> 分数<em>。</em></p>\n\n<p> </p>\n\n<p><strong>示例 1:</strong></p>\n\n<pre><strong>输入:</strong>nums = [1,2,3], multipliers = [3,2,1]\n<strong>输出:</strong>14\n<strong>解释:</strong>一种最优解决方案如下:\n- 选择末尾处的整数 3 ,[1,2,<strong>3</strong>] ,得 3 * 3 = 9 分,累加到分数中。\n- 选择末尾处的整数 2 ,[1,<strong>2</strong>] ,得 2 * 2 = 4 分,累加到分数中。\n- 选择末尾处的整数 1 ,[<strong>1</strong>] ,得 1 * 1 = 1 分,累加到分数中。\n总分数为 9 + 4 + 1 = 14 。</pre>\n\n<p><strong>示例 2:</strong></p>\n\n<pre><strong>输入:</strong>nums = [-5,-3,-3,-2,7,1], multipliers = [-10,-5,3,4,6]\n<strong>输出:</strong>102\n<strong>解释:</strong>一种最优解决方案如下:\n- 选择开头处的整数 -5 ,[<strong>-5</strong>,-3,-3,-2,7,1] ,得 -5 * -10 = 50 分,累加到分数中。\n- 选择开头处的整数 -3 ,[<strong>-3</strong>,-3,-2,7,1] ,得 -3 * -5 = 15 分,累加到分数中。\n- 选择开头处的整数 -3 ,[<strong>-3</strong>,-2,7,1] ,得 -3 * 3 = -9 分,累加到分数中。\n- 选择末尾处的整数 1 ,[-2,7,<strong>1</strong>] ,得 1 * 4 = 4 分,累加到分数中。\n- 选择末尾处的整数 7 ,[-2,<strong>7</strong>] ,得 7 * 6 = 42 分,累加到分数中。\n总分数为 50 + 15 - 9 + 4 + 42 = 102 。\n</pre>\n\n<p> </p>\n\n<p><strong>提示:</strong></p>\n\n<ul>\n\t<li><code>n == nums.length</code></li>\n\t<li><code>m == multipliers.length</code></li>\n\t<li><code>1 <= m <= 10<sup>3</sup></code></li>\n\t<li><code>m <= n <= 10<sup>5</sup></code><code> </code></li>\n\t<li><code>-1000 <= nums[i], multipliers[i] <= 1000</code></li>\n</ul>\n",
|
||||
"isPaidOnly": false,
|
||||
"difficulty": "Medium",
|
||||
"likes": 70,
|
||||
"likes": 73,
|
||||
"dislikes": 0,
|
||||
"isLiked": null,
|
||||
"similarQuestions": "[]",
|
||||
@@ -143,7 +143,7 @@
|
||||
"__typename": "CodeSnippetNode"
|
||||
}
|
||||
],
|
||||
"stats": "{\"totalAccepted\": \"4.7K\", \"totalSubmission\": \"12.4K\", \"totalAcceptedRaw\": 4684, \"totalSubmissionRaw\": 12396, \"acRate\": \"37.8%\"}",
|
||||
"stats": "{\"totalAccepted\": \"4.8K\", \"totalSubmission\": \"12.6K\", \"totalAcceptedRaw\": 4754, \"totalSubmissionRaw\": 12552, \"acRate\": \"37.9%\"}",
|
||||
"hints": [
|
||||
"At first glance, the solution seems to be greedy, but if you try to greedily take the largest value from the beginning or the end, this will not be optimal.",
|
||||
"You should try all scenarios but this will be costy.",
|
||||
|
||||
Reference in New Issue
Block a user